Node.js / Express.js - get path variable

0 points
Created by:
Dirask JS Member

In this article, we would like to show you how to get the path parameter in Express.js

We can get to the parameters we get in the path (for example ID) using the params property of the received request.


In place of the path, where we expect the parameter, we put :customVariable and we refer to it by request.params.customVariable.

Example with DELETE method: 

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

app.delete('/user/:id', (request, response) => {
    const id =;
    // ... delete user with given id

    response.send('User removed');


When received DELETE request is /user/5, then will be 5

Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂