I'm trying to simulate a POST request to a server app based in Express for nodeJS. It's running on localhost:3000
(JS Fiddle: http://jsfiddle.net/63SC7/)
I use the following CURL line:
curl -X POST -d "{\"name\": \"Jack\", \"text\": \"HULLO\"}" -H "Content-Type: application/json" http://localhost:3000/api
but get the error message:
Cannot read property 'text' of undefined
Any ideas what I'm doing wrong?
Note: I can make a successful GET request using this line:
curl http://localhost:3000/api
Assuming you're trying req.body.text
,
Have you use
d bodyParser
?
app.use(express.bodyParser());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With