Node JS Make HTTP Delete Request Example

About Us:

We are from free coder. We are a group of web developers who are passionate about web development. You can learn from us php, laravel, node js, vue js, react js and many other topic on web developement.
we are very happy to help you.
free coder

Today what you are going to learn:

Hello Brother,

Hello Brother, i will show you node js http delete request. This article will give you simple lesson of how to make http delete request nodejs. We will use node js axios delete request lesson. if you want to see lesson 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 lessons, using axios and request npm package for male delete http request using node js. let's see both lesson with output as bellow:

Lesson 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

Lesson 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

thank you very much for following up with me.

Tags

Recent Posts

Related Posts