I am using JQuery for sending async POST requests to the server and getting response values and seems to work well. However, I am getting the error you see in my question title and I do not know why since I do not do any GET request anywhere.
Client-side code:
async startGame(username) {
await fetch ($.post("/startGame", {username: username}, (data) => {
data = JSON.parse(data);
this.idPlayer = data[0];
this.idGame = data[1]
console.log("data1:");
console.log(data)
}));
await fetch ($.post("/lookingForAPlayer", (data) => {
data = JSON.parse(data);
console.log("data2:");
console.log(data)
}));
}
Server-side code (node.js):
app.post('/startGame', function(req, res) {
dbConnection.getIdPlayer(req.body.username).then(data1 => {
dbConnection.addGame(data1).then(data2 => {
res.end(JSON.stringify([data1, data2]));
});
});
});
app.post('/lookingForAPlayer', function(req, res) {
dbConnection.lookingForAPlayer().then(data => {
res.end(JSON.stringify(data));
});
});
Result:
Error is there:
As you can see, both requests have been made asynchronously, so it does what I need, but I do not think the error I am having is normal.