Last updated on Dec 16, 2022 by Suraj Sharma
In this tutorial, you will learn how to use an HTTP delete
method in javaScript using axios
library
To send an HTTP delete request using axios, we will use the delete()
method present in the axios module.
The delete
method accepts two arguments; a URL as the first argument and an optional config object as the second argument.
import axios from 'axios';
const userID = 123;
axios.delete(`/user/${userID}`, {
headers: {
'Authorization': 'Bearer <api token>',
}
}).then(response => {
console.log(response.data);
}).catch(error => {
console.log(error);
});
Related Solutions
Rate this post
Suraj Sharma is the founder of Future Gen AI Services. He holds a B.Tech degree in Computer Science & Engineering from NIT Rourkela.