I have the url of a basic resolution image. I need to upload images dynamically. After authorization, the image will be returned as data. How to handle this image with authorization. I am currently trying like this
<img [src]=" getImage(res.imageurl) | async" /> getImage(imageUrl: string): Observable<File> { let headers = new HttpHeaders(); headers = headers.append("Authorization", "Basic " + btoa(this.domain + '/' + logindata.username + ':' + logindata.password)); return this.http .get(imageUrl,{headers:headers}, { responseType: ResponseContentType.Blob }) .map((res: Response) => res.blob()); }
source share