2
I’m trying to send parameter to nodejs with restify, but it’s always coming undefined
I’m sending it sort of like this:
$.ajax({
url : 'http://localhost:8080/api',
type: 'post',
dataType: 'json',
data: {
ano : ano
}
})
And in the Ode I’m getting like this:
server.post('/api/temp/anual', async (req, res, next) =>{
try{
const { ano } = req.params
console.log( ano )
res.send( await db.medicao().anual( ano ) )
next()
}catch (error) {
res.send(error)
next()
}
})
Only the value always comes as undefined
If I try for Postman it will correct
I found out: I’ve changed
req.params
forreq.body
– adventistaam
Provide an answer to your own question as you discovered the answer :)
– Dherik