简体   繁体   中英

GET http://localhost:4200/[object%20Blob] 404 (Not Found) in Angular

I don't know but I can't recover image from Rest API; Please helpe me!

private baseUrl:string= "http://localhost:8080/";

Service:

public downloadeImageEcho1( id:number): Observable<any>{
  
  return this.http.get(this.baseUrl+"/downloadFile/"+id, { responseType: 'blob'});

}

component.ts:

getImage(id:number){
  this.serviceDossier.downloadeImageEcho1(id)
  .subscribe((data :any)=>{
    this.imageEcho=data;
    console.log(this.imageEcho); 
  })
}

html:

<div *ngIf = imageEcho>
            <img [attr.src]="imageEcho">
            
          </div>

error: enter image description here

thank you in advance!!

It would be better to set the image src to the URL of the image instead of fetching the image through the HTTP Client.

[attr.src]="imageEcho"

is causing the additional http request to occur.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM