Posts Learn Components Snippets Categories Tags 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

29 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.

Snippets by

PostSrc poster

PostSrc

Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.

Load comments for Axios Delete Request Example

new

PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your project.

View Components

Other Code Snippets

More