Just a few weeks until the 2021 JavaScript Full-Stack Bootcamp opens.
Signup to the waiting list!

POST query parameters are sent by HTTP clients for example by forms, or when performing a POST request sending data.

How can you access this data?

If the data was sent as JSON, using Content-Type: application/json, you will use the express.json() middleware:

const express = require('express')
const app = express()


If the data was sent using Content-Type: application/x-www-form-urlencoded, you will need to use the express.urlencoded() middleware:

const express = require('express')
const app = express()

  extended: true

In both cases you can access the data by referencing it from Request.body:

app.post('/form', (req, res) => {
  const name = req.body.name

Note: older Express versions required the use of the body-parser module to process POST data. This is no longer the case as of Express 4.16 (released in September 2017) and later versions.

Download my free Express.js Handbook

The 2021 JavaScript Full-Stack Bootcamp will start at the end of March 2021. Don't miss this opportunity, signup to the waiting list!

More express tutorials: