There is an Angular 4 client side Nodejs-Express back end and PostgreSQL database. The problem is that if I want to send data to server ( in my submodule, what is a todo function ) the backend send me the next:
My error message is:
POST /api/datatodo 500 1.150 ms - 969 error: invalid input syntax for integer: ""
modal.ts
class Searches {
_id: string;
title: string;
newdata: string;
constructor(
){
this.title = ""
this._id = ""
this.newdata = ""
}
}
the insert query on backend:
function createSearch(req, res, next) {
req.body.launched = parseInt(req.body.launched);
db.none('INSERT INTO table (userid, word)' +
'values(${_id}, ${newdata})',
req.body)
.then(function () {
res.status(200)
.json({
status: 'success',
message: 'Cool'
});
})
.catch(function (err) {
return next(err);
});
}