'having two type of content_type in case you have set one for all
it would be great if someone can help me with this issue.
i have set the header of all apis to "Content-Type": "application/json"
like the code below we have this code in a file that is imported in all api js files:
const httpClient = axios.create({
headers: {
"Content-Type": "application/json",
}
})
but now we need to have a different Content-Type for sending images with JSON content like 'Content-Type': 'multipart/form-data"
how can i define a new different header that renders every time we declare it
and how can i do this by code?
each api file that gets the Content-Type by default:
export const create = (data) => {
return httpClient({
url: '/api/create',
method: 'post',
headers: {
"X-CSRF-TOKEN"
},
data: data
})
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
