Answer the question
In order to leave comments, you need to log in
Why is data not sent from the server to the client via post?
The post request contains a query to the database
let data = pool.query("SELECT * FROM users");
res.send(data);
Answer the question
In order to leave comments, you need to log in
Accessing the database in NodeJS is asynchronous and sending the result should be in callback:
pool.query("SELECT * FROM users", (err, result)=>{
if (err) throw new Error(err.message);
res.send(result);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question