I am using Angular 6, and I'm trying to check if the _appconfig.json
file exists at root. If the file doesn't exist, I want to point the http.get() call to another URL. I can't seem to get things to behave like I want, though, and was wondering if someone could help me here.
What could I do change the URL if said file doesn't exist?
configUrl = "_appconfig.json";
constructor(private http: HttpClient) {}
data: any;
getConfig(): Promise<configType> {
return this.http
.get(this.configUrl)
.toPromise()
.then(response => response as configType)
.catch(this.handleError);
}
For what it's worth, this behaves as expected in the event that the file does exist.