Start extracting server communications to seperate module

This commit is contained in:
Ross
2020-10-20 11:35:38 +01:00
parent 5dfd0c4ff3
commit 6f70c5ed34
2 changed files with 29 additions and 26 deletions
+26
View File
@@ -0,0 +1,26 @@
/**
* Submits answers
*/
function submitAnswers() {
console.log(
getJsonAnswers().then((a) => {
postAnswers(a);
})
);
}
/**
* Posts answers to url
* @param {*} ans - json representation of answers
*/
function postAnswers(ans) {
console.log(ans);
// ans = {"test" : 1}
$.post("http://localhost:8000/submit_answers", JSON.stringify(ans)).done(
(data) => {
console.log(data);
}
);
// $.post( "http://localhost:8000/submit_answers", JSON.stringify(ans));
}