I want to display a certain image if it exists on a remote server. Otherwise, I want to show a different image. So I need a way of testing if an image exists on a remote server. I’m trying the following code, but it fails every time, even if the image is really there.
let observable = this.http.head(imageURL);
observable.subscribe(()=>{
console.log("Success! :)");
}, (error)=>{
console.log("Error :(");
}
The error message is something like “No ‘Access-Control-Allow-Origin’ header is present on the requested resource.” But this doesn’t make sense, because I can display the image just fine in my Ionic app if I choose to.
Any ideas?