PASSWORD RESET

Your destination for complete Tech news

How to get GET query parameter in Node js using express?

379 0
< 1 min read

To get the GET query parameters in an Express.js server, you can use the query property of the request object.

Here’s an example of how you can get the GET query parameters in an Express.js server using the query property:

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

app.get('/', (req, res) => {
  console.log(req.query); // { foo: 'bar', baz: 'qux' }
});

app.listen(3000);

In this example, the query property of the request object contains the GET query parameters as an object. You can access the individual query parameters using dot notation or bracket notation.

Express.js automatically parses the query string and assigns the values to the query property, so you don’t need to use a separate query string parsing library.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.