How to display response body using node.js and postman collection?
Last Updated :
24 Apr, 2025
This article includes step by step-by-step procedures to make a request to the API using Axios and display the response to the console as well as a visual view of the response in the Postman application.
What is Postman?
Postman is an API platform that is used to build and use APIs.
- It provides a user-friendly interface for sending and receiving HTTP requests to test, develop, and document APIs.
- Postman offers a range of features and tools that make it easier for developers to work with APIs.
What is Node.js?
Node.js is a cross-platform, open-source server environment that can run on Windows, Linux, Unix, macOS, and more. Node.js is a back-end JavaScript runtime environment, that runs on the V8 JavaScript engine and executes JavaScript code outside a web browser.
Why Display the Response Body?
A response body contains the data that is sent by the server in response to an http request.
- Displaying this information helps in understanding what is the data that is sent by the server and how to use it further as needed.
- We can use this body for debugging, logging or processing the data in our application.
Steps to Display Response Body
Step 1: Import Postman collection into Postman.
Import the postman collection in postman containing requests that we want to make from node.js.
1. Open postman and go to collections tab on the left-hand side. Click on "import" button located at the top-left corner.
2. In the "Import File" option, click on the "Choose Files" button and select the relevant postman collection file.
JavaScript
{
"info": {
"_postman_id": "unique-collection-id",
"name": "Simple Request Collection",
"description": "A basic Postman collection with a single request",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Sample Request",
"request": {
"url": "https://jsonplaceholder.typicode.com/posts/1",
"method": "GET"
}
}
]
}
3. Once the file has been selected, click on the "Import" button to initiate the import process.
4. After the import process is complete, you should see your newly imported collection listed in the Collections tab.
Step 2: Install packages.
Axios is an HTTP client for node.js and the browser. It can run in the browser and Node.js with the same codebase. Install the Axios package using the npm command:
npm install axios
Step 3: Write the node.js code to make an HTTP request and print the response to the console.
Below code snippet uses an axios package to make an http request and prints the response to the console:
Node
const axios = require('axios');
//postman collection URL
const apiUrl = 'https://api.example.com/endpoint';
const requestConfig = {
method:'GET',
headers: {
'Content-Type':'application/json',
},
//data
};
//api request using axios
axios(apiUrl, requestConfig)
.then((response)=> {
console.log('Response Body');
console.log(response.data);
}).catch((err) => {
console.error('Error:', err);
});
Step 4: Run code.
Run NodeJS code using command: -
node index.js
Step 5: Open Postman.
Open the postman application then navigate to collections. Here we have many options at the bottom side including body and header. Inside body there are many options in which we can see the body response as shown below:

Here we can see the body in different forms as shown below:
Pretty form
Raw form
preview (original look of response)Conclusion
In above article we have learnt what is postman, NodeJS. why we should display a response body. how to display a response body using NodeJS and postman collection.
Similar Reads
How to Set, View and Manipulate Cookies using 'Response.cookie()' and Postman ?
Cookies enable websites to store small pieces of information on a user's device. It helps enhance user experience and enable various functionalities. In this article, we'll explore a simple way to manipulate cookies using the 'Response.cookie()' functionPrerequisite:Basics of NodejsBasics of Express
2 min read
What are collections in Postman, and how to use them?
Postman is an Application Programming Interface (API) tool that streamlines the lifecycle of API development and testing efficiently. It can be used to develop, design, document, and test APIs.PrerequisitesBasic HTTP conceptsKnowledge of REST APITable of ContentWhat are collections in Postman?Advant
3 min read
How to organize requests within a Postman Collection?
Postman is very useful for testing the APIs. It has a feature to organize requests within a collection. Whether you are a beginner or an experienced user, understanding how to structure your requests can drastically enhance your work of testing the endpoints. In this guide, we will explore step-by-s
2 min read
How do you run Postman collections using Newman CLI?
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 run Postman collections using Newman CLI(Command Line Interface)Prerequisites:Node JS installed in your systemKnowledge about how APIs worksStep 1 :
2 min read
How to add nested object to existing JSON using Postman ?
Postman has become a critical tool for developers around the world, particularly when dealing with JSON data. This article will guide you through the process of adding nested objects to an existing JSON using Postman, with a focus on the approaches and syntax involved. Table of Content Understanding
4 min read
What are Postman Collections, and how do they organize requests?
Postman is a popular tool for working with APIs. It's user-friendly and has a cool feature called Collections. In this article, we will talk about what Collections are and how they help you organize and manage your API requests efficiently. PrerequisitesDownload and install PostmanBasic knowledge of
3 min read
How To Make A GET Request using Postman and Express JS
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 PrerequisitesNode JSExpress JSPostmanTable of Content What is GET Request?Steps to make a GET Request
3 min read
How to Count Records in JSON array using JavaScript and Postman ?
In this article, we are going to explore how JavaScript and Postman are used to count the number of records returned in a JSON array. Send a Request: Send a request to fetch the JSON array from your API endpoint in Postman.Access JSON Response: In the Postman test scripts tab, you can access the JSO
2 min read
How to Insert a Document into a MongoDB Collection using Node.js?
MongoDB, a popular NoSQL database, offers flexibility and scalability for handling data. If you're developing a Node.js application and need to interact with MongoDB, one of the fundamental operations you'll perform is inserting a document into a collection. This article provides a step-by-step guid
5 min read
Create, Use, and Run Postman Collections
Postman Collections are a powerful feature that enables users to organize and manage API testing and development. Collections consist of requests, which are APIs with a request and response format. In this article, we study the creation, utilization, and execution of Postman Collections with example
4 min read