I have a simple method to check if a *.mp3
file in my local machine exists or not.
It is supposed to return the status
of the response (200, 404,403,etc), but it doesn't work.
fileExists(url){
return this.http.get(url).timeout(2000)
.map(res=>res.json())
.subscribe(
res=>{
console.log("res is");
console.log(res.status)
return res.status;},
err =>{
console.log("Error is");
console.log(err.status);
return err.status});
}
I set a timeout for 2 seconds for it, however it only needs to check a file in my localhost. Therefore, i think, it has enough time to find the file.
it returns always:
Subscriber {closed: false, syncErrorValue: null, syncErrorThrown: false, syncErrorThrowable: false, isStopped: false…}