Skip to content

How to make an Axios DELETE request?

Making a DELETE request in Axios is very similar to making a POST or GET request. Let’s assume we are making a DELETE request to delete a user. The endpoint for the user is https://dev.poopcode.com/user

 axios.delete("https://dev.poopcode.com/user/anand", {
        headers: {
          Authorization: "xxxxxxx",
        }
      });

In the code snippet above we are passing userid in the url params.

Advertisements
 axios.delete("https://dev.poopcode.com/user",, {
        headers: {
          Authorization: "xxxxxxx",
        },
        data: {
          userId: "anand",
        },
      });

In the code snippet above we are passing userid in the body.

See also  Check if a path is file or directory in Node.js

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.