DEV Community

Discussion on: Build a Todo App with Node.Js, ExpressJs, MongoDB and VueJs – Part 1

Collapse
 
cyberrob profile image
Pek Bun Ong • Edited

Hi Samuel,thanks for the tutorial!

I clone from your repo and run on my mac with node v8.9.4.

After run node server.js, 127.0.0.1:4000 works fine. But running curl command like your:

$ curl -H "Content-Type: application/json" -X POST -d '{"name":"Going Shopping"}' localhost:4000/api/add

the server just hanging there not responding anything:

Note: Unnecessary use of -X or --request, POST is already inferred.

  • Trying 127.0.0.1...
  • TCP_NODELAY set
  • Connected to 127.0.0.1 (127.0.0.1) port 4000 (#0) > POST /api/add HTTP/1.1 > Host: 127.0.0.1:4000 > User-Agent: curl/7.54.0 > Accept: / > Content-Type: application/json > Content-Length: 25 >
  • upload completely sent off: 25 out of 25 bytes

After Ctrl+C, server showed:
node server.js
App listening on port 4000
POST /api/add - - ms - -

Could you help me out here? Thank you.

Collapse
 
_akash_j_ profile image
Akash Jobanputra • Edited

I was facing the same issue, after hours of searching, I found that downgrading the version of mongoose to 4.7.6 works.
I used below command to downgrade the mongoose module, and then the API worked perfectly.

npm install mongoose@4.7.6

Collapse
 
zsofiaboldizsar profile image
Zsofia Boldizsar • Edited

Thanks for sharing this, Akash. I should have looked at the comments section in the first place. I had the same issue, but with your tip, I managed to solve it.

Collapse
 
abiodunjames profile image
Samuel James • Edited

Hi Pek,

My bad! I'm just seeing this. I apologize for my late response.
Hope downgrading solves your problem as suggested by @Akash Jobanputra

Collapse
 
tvviem profile image
Triệu Vĩnh Viêm

We can use Postman app to send request form get/post. You will receive response data.