HTTP DELETE Requests with Body in Axios
Jul 7, 2021
To send a request body with an Axios DELETE request, you should set the data
option.
const res = await axios.delete('https://httpbin.org/delete', { data: { answer: 42 } });
res.data.json; // { answer: 42 }
Remember that the 2nd parameter to axios.delete()
is the Axios options, not the request body.
You can't pass the request body as the 2nd parameter like you can with axios.post()
or axios.put()
.
Did you find this tutorial useful? Say thanks by starring our repo on GitHub!