How To Make A GET Request using Postman and Express JS
Last Updated :
24 Jul, 2024
Postman is an API(application programming interface) development tool that helps to build, test and modify APIs. In this tutorial, we will see how To Make A GET Request using Postman and Express JS
Prerequisites
What is GET Request?
The GET Request is a HTTP request method used to get or retrieve the data from the specific resource on the server. The client sends the GET request to the server to retrieve the requested data or resource without affecting the server's state. Using the GET request, the client can fetch the resources like web pages, images, real-time data, etc.
Steps to make a GET Request using Postman and Express JS
Step 1: In the first step, we will create the new folder as a
a get-request by using the below command in the VS Code terminal.
mkdir get-request
cd get-request
Step 2: After creating the folder, initialize the NPM using the below command. Using this the package.json file will be created.
npm init -y
Step 3: Now, we will install the express dependency for our project using the below command.
npm i express
Step 4: Create a app.js file.
Project Structure:

The updated dependencies in package.json file will look like:
"dependencies": {
"express": "^4.18.2"
}
Example: Write the following code in the app.js file.
JavaScript
//app.js
const express = require('express');
const app = express();
const port = 3000;
// route for the root endpoint
app.get('/', (req, res) => {
res.send('Hello, Postman!');
});
// route for handling dynamic user IDs
app.get('/users/:userId', (req, res) => {
// Extract the user ID from the URL parameters
const userId = req.params.userId;
res.send(`Hello, User ${userId}!`);
});
// route for handling search with query parameters
app.get('/search', (req, res) => {
// extract the search query from the request's query parameters
const query = req.query.q;
res.send(`Search Results for: ${query}`);
});
// start the Express.js server and listen on the specified port
app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
});
Step 5: Start the server by using the below command.
node app.js
Step 6: Now, open the Postman application on the computer.

Step 7: Click on the "New" button and create two new requests. We will name them "Express-GET-Request1" and "Express-GET-Request2".

Step 8: Now, set the request type as GET, and in the URL section, enter the URL as "http://localhost:3000/users/1
" for Request 1 and "http://localhost:3000/search?q=postman
" for Request2.


Step 9: Now, we can click on the "Send" button of each request and check the responses in the Postman window.
Output:
Similar Reads
How to create routes using Express and Postman? In this article we are going to implement different HTTP routes using Express JS and Postman. Server side routes are different endpoints of a application that are used to exchange data from client side to server side.Express.js is a framework that works on top of Node.js server to simplify its APIs
3 min read
How to test GET Method of express with Postman ? The GET method is mainly used on the client side to send a request to a specified server to get certain data or resources. By using this GET method we can only access data but can't change it, we are not allowed to edit or completely change the data. It is widely one of the most used methods. In thi
2 min read
How to access Raw Body of a Post Request in Express.js ? Raw Body of a POST request refers to unprocessed or uninterpreted data sent in the request before Express or any middleware processes or understands it. It's like raw ingredients before the cooking begins. In this article we will see various approaches to access raw body of a post request in Express
3 min read
How to display Image in Postman using Express ? Postman is a powerful tool for testing APIs, but when it comes to displaying images, it can be a little bit tricky. This article, the process of setting up an Express server to serve images and accessing them using Postman.Prerequisites:PostmanExpress JSSteps to display Image in Postman:Step 1: Imag
2 min read
How to create and send GET requests in Postman? Postman is an API(application programming interface) development tool which helps to build, test and modify APIs. It has the ability to make various types of HTTP requests(GET, POST, PUT, PATCH), saving environments for later use, converting the API to code for various languages(like JavaScript, Pyt
1 min read
How to handle Basic Auth in Postman using Express. Authentication plays an important role in web development and API testing by making sure that only authorized individuals can access sensitive information or perform specific actions. Postman is a tool used for API development and testing. It offers support for managing different authentication meth
6 min read
How to test file uploads in Postman using Express? In web development, handling file uploads is a major requirement for various APIs. Postman is a powerful tool used for API testing, facilitates the process of testing file uploads. In this article we will see how we can test file upload with the help of Postman. Prerequisites:Node and NPM/Yarn insta
3 min read
How to create a new request in Postman? Postman is a development tool that is used for testing web APIs i.e. Application Programming Interfaces. It allows you to test the functionality of any application's APIs. Almost every developer uses Postman for testing purposes. We can create any type of HTTP request in it such as GET, POST, PUT, D
2 min read
How to Use Handle Get Request in Express.js ? Express.js is a popular web application framework for Node.js, known for its simplicity and flexibility. One of the fundamental tasks in web development is handling HTTP requests, and GET requests are among the most common. This article will guide you through the process of handling GET requests in
2 min read
How to Replicate Postman POST API Request using AJAX ? In this project we'll mimic the action of submitting data using POST to a server from a web page. We replicate this process using AJAX (Asynchronous JavaScript and XML) directly in a web page, we're embedding similar functionality within our own interface. This involves setting up HTML elements like
4 min read