I created a global function where Axios calls a URL and waits for a response (and returns true or false)
function ajaxRequestTrueFalse(url)
{
if(url == null)
{
var e = new Error("Veuillez saisir une URL");
throw e;
}
axios.post(url)
.then(function(response){
if(response.data.code === 200)
{
return true;
}
else
{
return false;
}
});
}
window.ajaxRequestTrueFalse = ajaxRequestTrueFalse;
But when I try to call it from somewhere:
var result = ajaxRequestTrueFalse(myUrl);
console.log(result);
I get directly "undefined" and only afterwards, the call from axios starts.
I would like to directly recover the expected result in my function, but I do not understand why it does not work