private validateURL(url: string) {
let isValid = false;
this.$http.get(url).then(
(data) => {
console.log('success');
isValid = true;
}
).catch(
(reason) => {
console.log('failure ' + reason);
isValid = false;
}
).then(
() => {
return isValid;
}
)
}
private checkURL() {
if (!this.validateURL(url)) {
alert('Incorrect URL');
return false;
}
}
The issue is that the alert in the if statement is being triggered before the validateURL
function is called. How can I ensure that the function is invoked first?