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);
});