I have been trying to get the value of my text input in a form with a POST request, but on the server side, the req.body
is returning a [objecet][Object]
The automatic string conversion in Javascript for an object is just [Object][object]
so when you do this:
console.log('The task is '+ req.body)
that's what is happening. req.body
undergoes an automatic string conversion to [Object][object]
and that's appended to your string.
To fix, change your code to this:
console.log('The task is ', req.body);
so that console.log()
can output the whole req.body
object.