I want to send a MySql "DateTime" var to a server. The var should be in this format: YYYY-MM-DD HH:MM:SS. The problem is when I try to send the var with fetch API to express, I get something like this: YYYY-MM-DD&20HH:MM:SS.
I have not tried anything so far
client-side:
var fetch = require("node-fetch");
function connectToServer(params) {
let url = "http://localhost:3000/" + params;
return new Promise((resolve, reject) => {
fetch(url).then(function(response) {
response = response.json();
resolve(response);
}).catch(error => {
reject(error);
});
});
};
let user = "A";
let time = "2020-07-07 11:00:00";
connectToServer(`joinQueue/${user}/${time}`).then(result => {
console.log(result)
}).catch(error => {
console.log(error);
});
**server-side*
joinQueue(user, time) {
const joinQueueQuery = `INSERT INTO queue VALUES("${user}", '${time}')`;
return new Promise((resolve, reject) => {
this.DB.queryDataBase(joinQueueQuery).then(result => {
resolve(true);
}).catch(error => {
reject(error);
});
});
}
}
when I print "joinQueueQuery", I get "2020-07-07T08:00:00.000Z" in the database. The problem is the hour in the database is 8 o'clock, although I sent 11.