From 648762d7a32b27fb43f6931aa93fc4022358ad1b Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Mon, 25 Jan 2021 18:59:16 +0100 Subject: idk --- questions/public/script.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'questions/public/script.js') diff --git a/questions/public/script.js b/questions/public/script.js index e5a03d0..aaeac00 100644 --- a/questions/public/script.js +++ b/questions/public/script.js @@ -30,7 +30,7 @@ fetch(`api/question/${qid}`) } else getNext(); // Resets }); -fetch(`api/questions`) +fetch("api/questions") .then((response) => response.json()) .then((response) => { for (const elem of response) { @@ -61,14 +61,14 @@ NodeList.prototype.on = function (listener, event) { for (const node of this) { node.addEventListener(listener, event); } -} +}; buttons.on("click", async (e) => { const body = JSON.stringify({ question: question_input.value, answer: e.target.dataset.value === "1", }); - const resp = await fetch(`api/answer`, { + const resp = await fetch("api/answer", { method, headers: { "Content-Type": "application/json" }, body, @@ -76,8 +76,8 @@ buttons.on("click", async (e) => { const res = await resp.json(); if (res.success) { method = "PUT"; - getNext(qid); + getNext(qid + 1); // document.querySelector(`.answer-btn[data-value="${e.target.dataset.value}"]`).style.opacity = "0.5"; // document.querySelector(`.answer-btn[data-value="${+!+e.target.dataset.value}"]`).style.opacity = "1"; // Let's not talk about it } -}); \ No newline at end of file +}); -- cgit v1.2.3