I am new to the react redux
. Here I have a delete request
export const deleterequest = (url, jdId) =>
axios.delete(
url,
jdId,
{
headers: {
"Authorization": localStorage.getItem("access_token") !== null ? `Bearer ` + localStorage.getItem("access_token") : null,
"Content-Type": "application/json"
}
}
).then(data => {
if (data.status === HttpStatus.OK) {
return {
status: data.status,
payload: data.data
};
}
}).catch(err => {
return {
status: err.response ? err.response.data : 'Network error',
payload: null
};
So, I tried with this apporch. jdId
is an array of strings. So, But when I am using in this way then my request header does not show this data.
So, what is that I am doing wrong. Can any one help me with this ?
delete requests with a body need it to be set under a data key
export const deleterequest = (url, jdId) =>
axios.delete(
url,
{ data: jdId },
{
headers: {
"Authorization": localStorage.getItem("access_token") !== null ? `Bearer ` + localStorage.getItem("access_token") : null,
"Content-Type": "application/json"
}
}
).then(data => {
if (data.status === HttpStatus.OK) {
return {
status: data.status,
payload: data.data
};
}
}).catch(err => {
return {
status: err.response ? err.response.data : 'Network error',
payload: null
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With