CodeSource code example

Axios Delete Example


In this article, you will learn how to make a delete request using Axios.

Let’s assume we have an array of objects containing a list of users, a list we probably have gotten from an endpoint.

    const users = [
        {
          name: "Jane Doe",
          location: "Texas",
          occupation: "Student",
        },
        {
          name: "John Michelle",
          location: "Berlin",
          occupation: "Trader",
        },
      ];

A simple delete call to delete the first object would look like thus:

 axios.delete("https://urltoendpoint/xxxxx", {
        headers: {
          Authorization: "xxxxxxx",
        },
        data: {
          user: users[0],
        },
      });

Share on social media

//