Hi Samuel!
I followed your first part of the tutorial, but my curl request didn't work. And my app didn't work, but my IDE didn't produce me any mistakes...
UPDATE
You missed the code:
app.listen(port, (err) => { if (err) { return console.log('something bad happened', err) } console.log(server is listening on ${port}) })
server is listening on ${port}
My app works with it.
This: curl -H "Content-Type: application/json" -X POST -d '{"name":"Going Shopping"}' localhost:4000/api/add
Show me this:
Unexpected token ' in JSON at position 0
Please, could you help me with it?
Hello Unika,
Sorry for my late response. Use this:
curl -X POST -H "Content-Type: application/json" \ -d "{\"name\":\"Going shopping\"}" http://localhost:4000/api/add
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Samuel!
I followed your first part of the tutorial, but my curl request didn't work.
And my app didn't work, but my IDE didn't produce me any mistakes...
UPDATE
You missed the code:
app.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(
server is listening on ${port}
)})
My app works with it.
UPDATE
This: curl -H "Content-Type: application/json" -X POST -d '{"name":"Going Shopping"}' localhost:4000/api/add
Show me this:
Unexpected token ' in JSON at position 0
Please, could you help me with it?
Hello Unika,
Sorry for my late response. Use this:
curl -X POST -H "Content-Type: application/json" \
-d "{\"name\":\"Going shopping\"}" http://localhost:4000/api/add