Node JS Make HTTP Delete Request Example
Hello,
Here, i will show you node js http delete request. This article will give you simple example of how to make http delete request nodejs. We will use node js axios delete request example. if you want to see example of http delete request body nodejs then you are a right place. you will do the following things for nodejs delete request api call.
i will give you two examples, using axios and request npm package for male delete http request using node js. let's see both example with output as bellow:
Example 1: HTTP DELETE Request using Axios
Create Node App:
mkdir my-request-app
cd my-request-app
npm init
Install Axios:
npm install axios --save
server.js
const axios = require('axios');
axios.delete('https://reqres.in/api/users/2')
.then((res) => {
console.log(`Status: ${res.status}`);
}).catch((err) => {
console.error(err);
});
Run App
node server.js
Output
Status: 201
Example 2: HTTP DELETE Request using Request
Create Node App:
mkdir my-request-app
cd my-request-app
npm init
Install Axios:
npm install request --save
server.js
const request = require('request');
const options = {
url: 'https://reqres.in/api/users/2',
json: true
};
request.delete(options, (err, res, body) => {
if (err) {
return console.log(err);
}
console.log(`Status: ${res.statusCode}`);
});
Run App
node server.js
Output
Status: 201
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to make an HTTP POST request in Node JS?
- Node JS Express Form Submission Example
- Node JS Mysql Connection Example
- Node JS Multer Rename Uploaded File Example
- Node JS Convert Image File to Base64 String Example
- Node JS Resize Image Before Upload using Multer Sharp
- Multiple File Upload in Node JS using Multer Example
- Node js Express Multiple Image Upload using Multer Example
- Node js Express Image Upload using Multer Example
- How to Connect MySQL Database in Node JS?