Farbod Aprin
Nov 23, 2020

--

Hey Jeyanth and others,

First of thanks for wonderful description, Just one point about the post it tooks 4 hour for me to find the issue!

I got response status 400 in postman ! and here is the solution, I believe that could be the different versioning of Node.js or Mdb.

in post,js

router.post("/", (req, res) => {

console.log("get the post request" + JSON.stringify(req.body));

instead of

//const { title, description } = req.body.toString();

define your req variable like this:

var title = req.body.title.toString();

var description = req.body.description.toString();

const post = new Posts({

title,

description,

});

post

.save()

.then((resp) => res.status(201).json(resp))

.catch((err) => res.status(400).json("Request Failed"));

});

--

--

Farbod Aprin
Farbod Aprin

Written by Farbod Aprin

Java Javascript developer, P.h.D Student in UDE university

Responses (1)