Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Building a MEAN Application Creating and Editing Data in a MEAN App Creating Data with POST Routes in Express

Christopher Parke
Christopher Parke
21,978 Points

Where does this dance thing come from???

All of a sudden there is a dance todo in postman. I don't have that. Did he type it in offscreen? God I hate that.

Hey Christopher! I was having the same problem until I figured out a solution.

Step 1: Check inside app.js and define the parser before the router.

app.use(parser.json());
app.use('/api', router);

Step 2: In POSTMAN when POST-ing, make sure that the body content is submitted as JSON (application/json) and not as Text as it is by default.

I hope this solves your problem.

Cheers

1 Answer

Jonathan Cousins
Jonathan Cousins
7,508 Points

He had it written off screen and pasted it in.

Here is the json he wrote:

{
  "name": "Dance",
  "completed": false
}

Note: Make sure you change the post body type from Text to JSON (application/json).