Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

506
Vistas
axios converts x-www-form-urlencoded to multipart/form-data

I am sending a post request with axios. However, when I check the browser console, I see that the request header is actually content-type: multipart/form-data. How can I enforce application/x-www-form-urlencoded? Or does it even matter?

let data = new FormData();
data.append('grant_type', 'authorization_code');
// ... removed for conciseness 
return axios.post(`${AUTH_URL}/token`, 
    data,
    {
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

FormData objects always serialise to multipart/form-data. They have to because they support file uploading and application/x-www-form-urlencoded and application/json do not.

If you want to send application/x-www-form-urlencoded data you should pass a URLSearchParams object instead.

This is described in the axios documentation.

In either case, you shouldn't specify the Content-Type in the headers since the underlying browser APIs will infer it correctly from the object type passed as the body data.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda