diff --git a/src/js/lib.js b/src/js/lib.js new file mode 100644 index 0000000..2b585dd --- /dev/null +++ b/src/js/lib.js @@ -0,0 +1,28 @@ + + +export async function post_request(url, body, form_status){ + let req; + + try { + req = await fetch(url, { + method: 'POST', + body: JSON.stringify(body), + mode: "cors" + }); + } catch (e) { + form_status.innerHTML = `${e}`; + return; + } + + if (req.status !== 200) { + form_status.innerHTML = "Failure"; + return; + } + + let temp = await req.json(); + if (temp.result === 'error') { + form_status.innerHTML = `${temp.error}`; + } else { + form_status.innerHTML = "Success"; + } +} \ No newline at end of file diff --git a/src/modify.html b/src/modify.html index f201542..2498418 100644 --- a/src/modify.html +++ b/src/modify.html @@ -49,7 +49,7 @@

- +