-3

I'm doing a MERN test project.

But at the time of testing a post method is not returning the value sent.

enter image description here

enter image description here

enter image description here

enter image description here

Any idea what the problem might be?

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Daniel Vera
  • 77
  • 1
  • 10

3 Answers3

1

use in app.js

app.use(express.json());

OR

If you want to simple boilerplate and Expressjs project structure then use Express application generator https://expressjs.com/en/starter/generator.html

Ankit Kumar Rajpoot
  • 5,188
  • 2
  • 38
  • 32
  • Looks like he had a mistake in the line you're indicating. Instead of using the use() method I had written unsubscribe(). The suggestion fixed the error. – Daniel Vera Oct 03 '19 at 21:15
  • Sorry Show this message: Thanks for the feedback! Votes cast by those with less than 15 reputation are recorded, but do not change the publicly displayed post score. – Daniel Vera Oct 03 '19 at 21:51
0

You just need to install body-parser

npm install body-parser --save

Check this link What does body-parser do with express?

Thomas Aumaitre
  • 651
  • 1
  • 7
  • 17
0

With the help of the comments detect the origin of the problem. A typing error ‍♂️ : when calling server.unsubscribe(express.json()) instead of using server.use(express.json());

Correcting this line fixed the problem. ✌

Daniel Vera
  • 77
  • 1
  • 10