Wednesday, 26 April 2017

Why bodyParser.json() is not working?

I am building an app with Node JS and Express.

In my app I use the following,

// middlewares
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
app.use(express.static('../web'))
app.use(morgan('dev'))

above all the app.get(), app.post().

My app goes well when I use Postman. It correctly fetches the data from the back end. But when I am using Google Chrome web browser, the req.body in app.get/post() is not working. It shows {}. That's why I am not able to fetch the data from the db. Front end Angular JS is used.



via Anijit

No comments:

Post a Comment