DEV Community

Discussion on: FullStack setup (Node.js, React.js and MongoDB)

 
tomrains profile image
tomrains

Here's what I'm getting:
thepracticaldev.s3.amazonaws.com/i...

So for some reason the response doesn't have the info I put in?

Thread Thread
 
pacheco profile image
Thiago Pacheco

Oh I see tomrains, you are sending a post request with a x-www-form-urlencoded, when you should actually be sending a json.
I think in postman you should select the option raw.

Give it a try and let me know if it worked! :)

Thread Thread
 
tomrains profile image
tomrains

It woooorked! Thanks so much Thiago. I'm having fun building my MERN app now :D

Thread Thread
 
pacheco profile image
Thiago Pacheco

Greaaaat!! Very glad to help :D

Thread Thread
 
francisvila profile image
Francis Vila

Hi Thiago,
I have a similar problem to the one reported by @tomrains , but the answer you gave did not allow me to solve it.
(Note: I'm new to Postman)
the response I get for localhost:5000/api/product?name=to... is
{"error":false,"product":{"id":"5ee204bbf1af38409c11d4de","_v":0}}
the response code is 201 Created.
In the Pretty - Raw - Preview section, I can't edit, it's read only
I added a Content-type: raw section in the headers but that didn't change anything.
I tried using curl, with this command: curl --location --request POST "localhost:5000/api/product" --header "Content-Type: raw" -d '{"name":"toto","description":"tata"}'
but the result seems to be the same...

Here's a screenshot of my postman app:
dev-to-uploads.s3.amazonaws.com/i/...

Thread Thread
 
pacheco profile image
Thiago Pacheco

Hi Francis.

In your screenshot, I can see that you are sending query params with the values when you should actually be sending body data in postman.
You can select the body option and you will have a raw option below it.

Follow a screenshot below with an example:
dev-to-uploads.s3.amazonaws.com/i/...

Thread Thread
 
francisvila profile image
Francis Vila

thank you so much, Thiago! That was really quick! It works now. It seems obvious once you know where to look.