Answer the question
In order to leave comments, you need to log in
Why isn't the POST (fetch) body coming?
Customer:
fetch('/chat', {
method: 'POST',
body: `INSERT INTO messages (textMessage, timeMessage, userName) VALUES ('hi', '2500-01-01' , 'Yana')`
})
router.post('/',function(req,res,next){
console.log('post!!!', req.body);
});
post!!! {}
Answer the question
In order to leave comments, you need to log in
Problem solved like this.
Customer:
fetch('/chat', {
headers: {body: `INSERT INTO messages (textMessage, timeMessage, userName) VALUES ('hi', '2500-01-01' , 'Yana')`},
method: 'POST',
})
router.post('/',function(req,res,next){
console.log('post!!!', req.headers.body);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question