let someFunc = async () => {
try{
let data = await dbreq();
let res = await anyreq(data);
console.log(res)
}
catch(err){
console.log(err);
}
}
let someFunc = async () => {
try{
let data = await dbreq();
catch(err){
console.log(err);
}
try{
let res = await anyreq(data);
console.log(res)
catch(err){
console.log(err);
}
}
let form = document.querySelector('form');
form.onsubmit = e => {
e.preventDefault();
let res = document.querySelector('.result');
axios({
method: 'POST',
url: '/test',
data: {
'input1': document.querySelector('input[name="input1"]').value,
'input2': document.querySelector('input[name="input2"]').value,
'textarea': document.querySelector('textarea[name="textarea"]').value
}
}).then( () => {
res.innerHTML = 'Form was successfully sent!';
form.reset();
}).catch( ()=> {
res.innerHTML = 'An error occurred!';
form.reset();
});
};
};