I'm writing a quiz app, where the frontend GETs a question from the server database using Fetch API, then sends both question and answer again via Fetch API to django on the server, which then is supposed to check against the data base if the answer is correct or not. As of now the checking doesn't change anything on the server (though in the future it'll change points for the user depending on if the answer was correct). Should I then be using PUT or POST as method? I cannot use GET, because a GET method cannot have a body for parameters.
const setup = {
credentials: "same-origin",
method: 'PUT' or 'POST'?,
body: JSON.stringify({
"answer": 'is answer',
"question": 'is question'
}),
headers: {
"X-CSRFToken": getCookie("csrftoken"),
"Accept": "application/json",
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
},
};
const response = await fetch('/exercises/get_exercise', setup);
that's my fetch request. Also happy to hear any other comments on the code!