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

208
Vistas
How to POST form data with axios?

I'm trying to set up post requests using Axios. The post request gets sent and received but I want to make it so that whatever I put into the text box gets sent in the said post request.

(This is my first time using Javascript and node.js and using CSS please keep such in mind)

my HTML:

 <form action="/Stanza" method="post"></form>
          <input class="btn btn-primary mx-auto h-8 app-title mt-2 bg-purple-600 rounded-lg p-4 text-center overflow-hidden xl:my-4 xl:px-4 w-1/6 placeholder-white" id="setPrize" type="text" onchange="updatevariable(stanza)" onclick="setStanza();" placeholder="Enter a stanza"/>
          <input class="btn btn-primary mx-auto h-8 app-title mt-2 bg-purple-600 rounded-lg p-4 text-center overflow-hidden xl:my-4 xl:px-4 w-1/6 placeholder-white" onclick="gay2();" placeholder="Jid/@">Victim</button>
         <input class="btn btn-warning mx-auto h-8 app-title mt-2 bg-purple-600 rounded-lg p-4 text-center overflow-hidden xl:my-4 xl:px-4 w-1/6" id="prize" type="text" onclick="clearOutput()"/>
            <div class="panel-body" id="getResult1"></div>```

My axios:

let stanza = "";

 function setStanza(value){
    stanza = value;
}

onchange="setStanza(this.​value)"

let victim = 'gay';

var element = document.getElementById("myInput");
element.onchange = axios.post('/Stanza', {stanza})
.then(function gay (response) {
  console.log(response);
  console.log(element.value);
})
.catch(function gay2 (error) {
  console.log(error);
});

My express:

app.post('/Stanza', function(req, res) {
    console.log('receiving data ...');
    console.log('body is ',req.body);
    res.send(req.body);
});
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