I get this error while posting to SQL:
C:\API\node_modules\mssql\lib\msnodesqlv8\request.js:276
const err = new RequestError(info, 'EREQUEST')
app.post('/info/Post',(req,res)=>{
console.log(req.body)
res.send(req.body)
let data = [req.body.ID, req.body.Name,req.body.Appointment,req.body.Technology,req.body.Task] ;
sql.query('Insert into info(ID,Name,Appoinment,Technology,Task) values (?,?,?,?',data,(err,rows,fields)=>{
if(!err)
//console.log(rows);
res.send('rows');
else
console.log(err);
})
});
postman msg
{
"ID":"30",
"Name":"DG",
"Appointment":"test",
"Technology":"test",
"Task":"test"
}
Hey @mission-pilot-245071
Welcome to the Postman Community!
This feels more likely a Stackoverflow question than something the would be answered on this forum but I think it might be a syntax error:
'Insert into info(ID,Name,Appoinment,Technology,Task) values (?,?,?,?'
I think you haven’t closed off the values correctly, it should have a )
before the last quote.
It also looks like you have a miss match on the word Appointment
Thanks for the reply! I saw the missing close bracket and the miss match word. I corrected those and the same error.
Danny:
res.send(req.body)
Is this needed?
Wouldn’t that try and send a response before the SQL query completes?
I added that just to test what’s being sent to node.
on postman this is the error:
Error: read ECONNRESET
It’s not a Postman error as such, you just happen to be using Postman to see the response from your server or lack of response in this case.
As I mentioned previously, this is a question that’s better asked on Stack Overflow as you would get a wider range of people with the necessary experience to answer the question.
These might help:
Thanks! I will check that out.
2 Likes
system
(system)
Closed
August 10, 2024, 5:18pm
9
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.