diff options
author | 2023-08-10 19:46:45 -0700 | |
---|---|---|
committer | 2023-08-10 20:29:34 -0700 | |
commit | 168a870c025bfef6efdeb46e166e79a16093c157 (patch) | |
tree | 4d8ab69c7e3ef03a7ade06e7b5e5053429a64c3b /ui/static/js/request_builder.js | |
parent | c2349032552891745cbbc3d2a9e772845a0239f4 (diff) | |
download | v2-168a870c025bfef6efdeb46e166e79a16093c157.tar.gz v2-168a870c025bfef6efdeb46e166e79a16093c157.tar.zst v2-168a870c025bfef6efdeb46e166e79a16093c157.zip |
Move internal packages to an internal folder
For reference: https://go.dev/doc/go1.4#internalpackages
Diffstat (limited to 'ui/static/js/request_builder.js')
-rw-r--r-- | ui/static/js/request_builder.js | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/ui/static/js/request_builder.js b/ui/static/js/request_builder.js deleted file mode 100644 index e19168fc..00000000 --- a/ui/static/js/request_builder.js +++ /dev/null @@ -1,48 +0,0 @@ -class RequestBuilder { - constructor(url) { - this.callback = null; - this.url = url; - this.options = { - method: "POST", - cache: "no-cache", - credentials: "include", - body: null, - headers: new Headers({ - "Content-Type": "application/json", - "X-Csrf-Token": this.getCsrfToken() - }) - }; - } - - withHttpMethod(method) { - this.options.method = method; - return this; - } - - withBody(body) { - this.options.body = JSON.stringify(body); - return this; - } - - withCallback(callback) { - this.callback = callback; - return this; - } - - getCsrfToken() { - let element = document.querySelector("body[data-csrf-token]"); - if (element !== null) { - return element.dataset.csrfToken; - } - - return ""; - } - - execute() { - fetch(new Request(this.url, this.options)).then((response) => { - if (this.callback) { - this.callback(response); - } - }); - } -} |