#express js #api #node #node js #web services

How to get post data in json in express JS APIs - Node JS

Thought it sounds simple and straight forward, this thing killed a lot of my time at the initial time of getting into node JS.

the query string are directly available in the request for both get and post methods but to get the post data you send in json format you need to update you express JS index.js . In the root of your express JS setup you have index.js add the following line on the top after the creation of app.

app.use(express.json());

Now you will be able to access the json data in post request in req.body

If you are facing the same issue with your form submits, please follow the link for the solution.