private isValidURL(url: string) {
var 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 anotherFunc() {
if (!this.isValidURL(url)) {
alert('Wrong URL');
return false;
}
}
The alert inside the if statement is executing prior to the isValidURL
's function call. How do I ensure that the function is executed first?