diff --git a/src/main/resources/static/main.js b/src/main/resources/static/main.js index 65c62d6..28c6acc 100644 --- a/src/main/resources/static/main.js +++ b/src/main/resources/static/main.js @@ -123,18 +123,16 @@ export function vote(entryID, up) { ); console.log(fetchURL); // TODO: remove fetch(fetchURL, { - method: "PUT", //mode: 'no-cors' + method: "PUT", headers: { 'Content-Type': 'application/json', - // Add other headers as needed - }, - }); - /*.then(resp => resp.json()) // TODO: wait for backend + }}) + .then(resp => resp.json()) .then((data) => { - console.log(data.content); // TODO: remove*/ + console.log(data.upvotes); // TODO: remove, check einbauen: data.id === entryID? let dataset = document.querySelector('[data-id= ' + CSS.escape(entryID) + ']') - dataset.querySelector("span").innerText++; // TODO: replace by parsed vote - /*});*/ + dataset.querySelector("span").innerText = data.upvotes; + }); } function incrementPageCount() {