Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!