Reputation: 121
I'm trying to determine whether file exists, by using httpclient's method get.
Then based on the outcome if file exists or not call one method with different argument.
public faviconLogic(iconName: string): void {
this.getFile(`assets/favicon/${iconName}/favicon.ico`)
.subscribe(
() => this.setFavicon(iconName),
() => this.setFavicon('default')
);
}
private getFile(filename: string): Observable<Blob> {
return this.http.get(filename, { responseType: 'blob' });
}
When entering method faviconlogic I get error
TypeError: Cannot read property 'length' of undefined
at t.applyUpdate
I tried adding headers - nothing. Calling method getFile itself works without problem lays with subscription to Observable returned on get. What am I doing wrong?
Upvotes: 0
Views: 386