Node.js Query String

The querystring module is used to work with query parameters in URLs.

Example

const querystring = require("querystring");

const data = querystring.parse(
    "name=Madhu&age=20"
);

console.log("Name:", data.name);
console.log("Age:", data.age);
        
Example Output:

Name: Madhu
Age: 20

Explanation

  1. Import the querystring module.
  2. Give the query string.
  3. Use parse() to convert it into an object.
  4. Access the values using their names.
← Back to Home