Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

211
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda