How to display response body using node.js and postman collection?
Last Updated :
23 Jul, 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.postman.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
Software Testing Tutorial Software testing is an important part of the software development lifecycle that involves verifying and validating whether a software application works as expected. It ensures reliable, correct, secure, and high-performing software across web, mobile applications, cloud, and CI/CD pipelines in DevOp
10 min read
What is Software Testing? Software testing is an important process in the Software Development Lifecycle(SDLC). It involves verifying and validating that a Software Application is free of bugs, meets the technical requirements set by its Design and Development, and satisfies user requirements efficiently and effectively.Here
11 min read
Principles of Software testing - Software Testing Software testing is an important aspect of software development, ensuring that applications function correctly and meet user expectations. From test planning to execution, analysis and understanding these principles help testers in creating a more structured and focused approach to software testing,
3 min read
Software Development Life Cycle (SDLC) Software Development Life Cycle (SDLC) is a structured process that is used to design, develop, and test high-quality software. SDLC, or software development life cycle, is a methodology that defines the entire procedure of software development step-by-step. The goal of the SDLC life cycle model is
8 min read
Software Testing Life Cycle (STLC) The Software Testing Life Cycle (STLC) is a process that verifies whether the Software Quality meets the expectations or not. STLC is an important process that provides a simple approach to testing through the step-by-step process, which we are discussing here. Software Testing Life Cycle (STLC) is
7 min read
Types of Software Testing Software testing is a important aspect of software development life-cycle that ensures a product works correctly, meets user expectations, and is free of bugs. There are different types of software testing, each designed to validate specific aspects of an application, such as functionality, performa
15+ min read
Levels of Software Testing Software Testing is an important part of the Software Development Life Cycle which is help to verify the product is working as expected or not. In SDLC, we used different levels of testing to find bugs and errors. Here we are learning those Levels of Testing in detail.Table of ContentWhat Are the Le
4 min read
Test Maturity Model - Software Testing The Test Maturity Model (TMM) in software testing is a framework for assessing the software testing process to improve it. It is based on the Capability Maturity Model(CMM). It was first produced by the Illinois Institute of Technology to assess the maturity of the test processes and to provide targ
8 min read
SDLC MODELS
TYPES OF TESTING