I have a problem with axios, i cant set content type to multipart/form-data. here's my code
function (config) {
// Do something before request is sent
const isLogin = authService.isLogin();
if (isLogin) {
const _auth = JSON.parse(isLogin);
// const _superadmin = `cHJhdG9tby5hLm51Z3JvaG9AZ21haWwuY29tOmJlMTNlOTE1Yjg4MzEyMmVlMGRhNzZlNzBiYWU3ZjU1OTJmMGZlZGNiZTYzNWEyZmMyMDg0MWZhOGI3ZGQ0ZWQ=`;
config.headers["Authorization"] = authService.isLogin()
? "Bearer " + _auth._token
: "";
config.headers["Accept"] = "application/json, text/plain, */*";
config.headers["Content-Type"] = "multipart/form-data";
}
return config;
}, ```
does anyone can help me to add content-type in my header request?
Axios does not automatically set the multipart form boundary in Node, as a result, you must use getHeaders()
like :
const res = await axios.post('https://www.example.com/post', formData, {
headers: formData.getHeaders()
});
in your case config.getHeaders() while you are sending the request