Quantcast
Channel: Express.js req.body undefined - Stack Overflow
Viewing all articles
Browse latest Browse all 54

Answer by John Nico Novero for Express.js req.body undefined

$
0
0

UPDATE 2022

You can just use.

app.use(express.json())

const express = require('express')const app = express();const PORT = process.env.PORT || 3001// Calling the express.json() method for parsingapp.use(express.json())app.listen(PORT, () => {    console.log(`============ API Gateway is open at ${PORT} ============= `)})

express.json() is a built-in middleware function in Express. This method is used to parse the incoming requests with JSON payloads and is based upon the bodyparser.

This method returns the middleware that only parses JSON and only looks at the requests where the content-type header matches the type option.

express.json vs bodyParser.json


Viewing all articles
Browse latest Browse all 54

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>