diff options
author | rubenwardy <rw@rubenwardy.com> | 2018-05-11 15:14:35 +0100 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2018-05-11 15:14:35 +0100 |
commit | 6d7b810270b21575dca54eb36f371969b976bafd (patch) | |
tree | 614ed0d07cf9557b27eb9c7c5fdeeddc15bce238 /app/static/package_create.js | |
parent | 92717f31dd94ad1c763641a397305de9bc143df9 (diff) | |
download | cheatdb-6d7b810270b21575dca54eb36f371969b976bafd.tar.xz |
Add login_required to task APIs
Diffstat (limited to 'app/static/package_create.js')
-rw-r--r-- | app/static/package_create.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/static/package_create.js b/app/static/package_create.js index 89b21bc..927273f 100644 --- a/app/static/package_create.js +++ b/app/static/package_create.js @@ -6,9 +6,15 @@ $(function() { $(".pkg_meta").show() } - function getJSON(url) { + function getJSON(url, method) { return new Promise(function(resolve, reject) { - fetch(url).then(function(response) { + fetch(new Request(url, { + method: method || "get", + credentials: "same-origin", + headers: { + "Accept": "application/json", + }, + })).then(function(response) { response.text().then(function(txt) { resolve(JSON.parse(txt)) }).catch(reject) @@ -18,7 +24,7 @@ $(function() { function performTask(url) { return new Promise(function(resolve, reject) { - getJSON(url).then(function(startResult) { + getJSON(url, "post").then(function(startResult) { console.log(startResult) if (typeof startResult.poll_url == "string") { var tries = 0; |