{"pageProps":{"post":{"title":"How to send a delete request in axios","excerpt":"Learn how to send a delete request in javaScript using axios","date":"2022-12-16T00:00:00.000Z","slug":"axios-delete-request","author":{"name":"Suraj Sharma","picture":""},"content":"\n
\n\nIn this tutorial, you will learn how to use an HTTP `delete` method in javaScript using `axios` library\n\n
\n\nTo send an HTTP delete request using axios, we will use the `delete()` method present in the axios module.\n\n
\n\nThe `delete` method accepts two arguments; a URL as the first argument and an optional config object as the second argument.\n\n
\n\n```javascript\nimport axios from 'axios';\n\nconst userID = 123;\n\naxios.delete(`/user/${userID}`, {\n headers: {\n 'Authorization': 'Bearer ',\n }\n}).then(response => {\n console.log(response.data);\n}).catch(error => {\n console.log(error);\n});\n```\n\n
\n
\n\n**Related Solutions**\n\n- [How to submit form data in post request using axios](/blog/axios-post-form-data)\n\n- [How to upload files in React using Axios](/blog/react-upload-file-using-axios)\n\n- [How to handle an error in async await in JavaScript](/blog/error-handling-in-javascript-async-await)\n\n- [How to loop through an array of objects in React](/blog/for-loop-in-react)\n\n
\n","coverImage":{"url":"/images/cover-image.png"},"url":"axios-delete-request","hashtags":"#javascript #axios"}},"__N_SSG":true}