Posts Learn Components Snippets Categories Tags Tools About
/

Axios Delete Request Example

Learn how to use the delete method in axios HTTP client to remove a resource from an external API

Created on Aug 30, 2021

718 views

In this short snippet, you will learn how to perform delete request in Axios.

Fake API for DELETE request


For this tutorial, we'll be using a fake API from JSONPlaceholder, and below is the endpoint.
https://jsonplaceholder.typicode.com/posts/1

Axios Delete Request Code Example


To perform a DELETE request in Axios you can call the "delete" method of the "axios" object. This method accepts the resource URL and if there's any configuration then it can be passed as the 2nd parameter.
<script>
    import axios from 'axios';

    const response = await axios
        .delete('https://jsonplaceholder.typicode.com/posts/1');

    console.log(response);
</script>
Do note that the resource will not be really updated on the server but it will be faked as if.

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

Load comments for Axios Delete Request Example

)