I am testing my post method on Postman. Whenever I post the result it would display empty array []. I console logged it on the node side and it returns empty array as well.
CREATE TABLE users (
user_id SERIAL PRIMARY KEY,
username TEXT,
email TEXT,
password TEXT
)
INSERT INTO users (username, email, password) VALUES ($1, $2, $3);
app.post('/api/users', function(req, res, next) {
db.post_user([req.body.username, req.body.email, req.body.password], function(err, user) {
console.log(user);
if(err) res.status(500).send(err);
else res.json(user);
})
})
I am not exactly sure why I am getting empty array instead of actual data passing in.
via Yh1234
No comments:
Post a Comment