DEV Community

Mohammed Samgan Khan
Mohammed Samgan Khan

Posted on • Originally published at codebysamgan.com

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());
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)