I am building an app using node.js and knex for the ORM. I want my insert command to send either a success or error response, but it is not working for some reason:
knex('reports').insert({
reportid: reportId,
created_at: currentDate
}).then().catch(function(error) {
if(error) {
console.log("error!!!: " + error)
res.send(400, error);
} else {
console.log('no error');
res.send(200);
}
});
The code as is does NOT console.log out the error nor lack of error.
Note - the res.send(200) should go back to my client side to alert the client the request was successful.
Can someone help? Thanks in advance!!
.catchwhat else can I use to get the desired effect?