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

236
Vistas
Axios POST request - setting headers

I am trying to mimic a form submit with an Axios post request - to be more precise, I am trying to turn this:

<form method="POST" action="https://testpaymentgateway...">
    
<input type="text" name="amount" value="1000"/>
    
<input type="submit" text="submit"/>
    
</form>

into something like this:

let paymentData = new FormData();

paymentData.append('amount','1000');

axios.post('https://testpaymentgateway...', paymentData, {
    
headers: {
     
'content-type': 'application/x-www-form-urlencoded',
    
'sec-fetch-mode': 'navigate'
    
}
    
})
    
.then(function (response) {
    
console.log(response);
    
})
    
.catch(function (response) {
    
console.log(response);
    
});

The first example with manually submitting the form works ok, while the axios post request returns a CORS error. I have compared the two requests and found that some of the headers are different, however, the axios request doesn't seem to set the headers I'm trying to set, the content-type is always "multipart/form-data" and sec-fetch-mode is always "cors". I have tried different ways of setting the headers object, but none of them are working. Any idea why this might be happening?

about 4 years ago · Juan Pablo Isaza
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