Trying to use a pure JS approach to check if I have a valid JS image url. I am getting a warning that XMLHttpRequest
is deprecated. What is a better way to do this?
urlExists(url) {
const http = new XMLHttpRequest();
http.open('HEAD', url, false);
http.send();
if (http.status !== 404) {
return true;
}
return false;
}