Tengo un problema con axios, no puedo establecer el tipo de contenido en multipart/form-data. aquí está mi código
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 no establece automáticamente el límite del formulario de varias partes en Node, como resultado, debe usar getHeaders()
me gusta :
const res = await axios.post('https://www.example.com/post', formData, { headers: formData.getHeaders() });en su caso, config.getHeaders() mientras envía la solicitud