Reading Query Parameters in Node Last Updated : 17 Oct, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report In Node.js, query parameters are typically accessed from the URL of a GET request. When using the core HTTP module or a framework like Express, query parameters can be parsed and accessed for dynamic functionality.A query string refers to the portion of a URL (Uniform Resource Locator) that comes after the question mark (?). Its purpose is to transmit concise data to the server directly through the URL. Typically, this data serves as a parameter for querying a database or filtering results.The query parameter is the variable whose value is passed in the URL in the form of a key-value pair at the end of the URL after a question mark (?). For example:www.geeksforgeeks.org?name=abcwhere 'name' is the key of the query parameter whose value is 'abc'.ApproachTo Read query parameters in Node we will be using Express.js's req.query method. Parse the URL, extract parameters, and use them in the server-side logic for customization or filtering.Steps to create the ApplicationStep 1: Initializing the Node App using the below command:npm init -yStep 2: Installing the required packages:npm install express ejsProject Structure:The updated dependencies in package.json file will look like:"dependencies": { "express": "^4.18.2", "ejs": "^3.1.9",}Example: This example demonstrates readign query parameters name and age from the URL, logs them to the console. JavaScript // Filename - index.js const express = require("express") const path = require('path') const app = express() const PORT = process.env.port || 3000 // View Engine Setup app.set("views", path.join(__dirname)) app.set("view engine", "ejs") app.get("/user", function (req, res) { const name = req.query.name const age = req.query.age console.log("Name :", name) console.log("Age :", age) }) app.listen(PORT, function (error) { if (error) throw error console.log("Server created Successfully on PORT", PORT) }) Steps to run the program:node index.jsOutput: Go to this URL "http://localhost:3000/user?name=raj&age=20" as shown below: Console Output: Comment More infoAdvertise with us G gouravhammad Follow Improve Article Tags : Node.js Node.js-Misc Similar Reads REST API Introduction REST API stands for REpresentational State Transfer API. It is a type of API (Application Programming Interface) that allows communication between different systems over the internet. REST APIs work by sending requests and receiving responses, typically in JSON format, between the client and server. 7 min read NodeJS Interview Questions and Answers NodeJS is one of the most popular runtime environments, known for its efficiency, scalability, and ability to handle asynchronous operations. It is built on Chromeâs V8 JavaScript engine for executing JavaScript code outside of a browser. It is extensively used by top companies such as LinkedIn, Net 15+ min read Node.js Tutorial Node.js is a powerful, open-source, and cross-platform JavaScript runtime environment built on Chrome's V8 engine. It allows you to run JavaScript code outside the browser, making it ideal for building scalable server-side and networking applications.JavaScript was mainly used for frontend developme 4 min read JSON Web Token (JWT) A JSON Web Token (JWT) is a standard used to securely transmit information between a client (like a frontend application) and a server (the backend). It is commonly used to verify users' identities, authenticate them, and ensure safe communication between the two. JWTs are mainly used in web apps an 7 min read Express.js Tutorial Express.js is a minimal and flexible Node.js web application framework that provides a list of features for building web and mobile applications easily. It simplifies the development of server-side applications by offering an easy-to-use API for routing, middleware, and HTTP utilities.Built on Node. 4 min read Backend Development Backend Development involves the logic, database, and other operations that are built behind the scenes to run the web servers efficiently. Backend Development refers to the server-side development of the web application. It is the part of the application where the server and database reside and the 12 min read How to Update Node.js and NPM to the Latest Version (2025) Updating Node.js and NPM to the latest version ensures the newest features, performance improvements, and security updates. This article will guide you through the steps to update Node.js and npm to the latest version on various operating systems, including Windows, macOS, and Linux.Different Method 3 min read How to Download and Install Node.js and NPM NodeJS and NPM (Node Package Manager) are essential tools for modern web development. NodeJS is the runtime environment for JavaScript that allows you to run JavaScript outside the browser, while NPM is the package manager that helps manage libraries and code packages in your projects.To run a Node. 3 min read NodeJS Introduction NodeJS is a runtime environment for executing JavaScript outside the browser, built on the V8 JavaScript engine. It enables server-side development, supports asynchronous, event-driven programming, and efficiently handles scalable network applications. NodeJS is single-threaded, utilizing an event l 5 min read Web Server and Its Types A web server is a systemâeither software, hardware, or bothâthat stores, processes, and delivers web content to users over the Internet using the HTTP or HTTPS protocol. When a userâs browser sends a request (like visiting a website), the web server responds by delivering the appropriate resources, 7 min read Like