Контролировать подачу формы на основе ответа APIHtml

Программисты Html
Anonymous
Контролировать подачу формы на основе ответа API

Сообщение Anonymous »

Я хочу отправить свою форму в зависимости от ответа API.

Код: Выделить всё


Submit

function getResult(){

function makeGetRequest(path) {
return new Promise(function (resolve, reject) {
axios.get(path).then(
(response) => {
var result = response.data;
resolve(result);
},
(error) => {
reject(error);
}
);
});
}

async function main() {
var emailAdd = (document.getElementById('inf_field_Email').value);
if (emailAdd != ""){

var result = await makeGetRequest(server+emailAdd);
let form = document.getElementById('myFormID');

if (result.status == 'valid'){
form.action = "https://nextpage.com";
return true;

}
else
{
return false;
}
}

else{

console.log('Please put email address')
}
}

main();

}
У меня есть этот код, однако он просто перезаряжаюсь после того, как я нажимаю кнопку «Отправить»

Подробнее здесь: https://stackoverflow.com/questions/755 ... i-response

Вернуться в «Html»