3

I hit my api and get back a base64 string which I want to populate as an image on angular2 frontend.

This is how my service looks like:

private myUrl: string = 'http://127.0.0.1:8000/api/gallery/'

constructor(private http: Http){

}

fetchGallery(id: number){


    return this.http.get( this.myUrl + id + '/', {withCredentials: true})
    .toPromise()
    .then(response => response.json())

}

I call this service through my component:

fetchGallery(id: number){

        this.galleryService.fetchGallery(id)
        .then( 
            response => {
                this.gallery = response;
            });
    }

And on HTML:

<div *ngFor="let image of gallery">
  <img [src]="'data:image/png;base64,'+image">
</div>

As a response I get back:

["data:image/jpg;base64,--base64 string--"]

It gives me error saying:

WARNING: sanitizing unsafe URL value

Where and what should I correct?

Thinker
  • 5,326
  • 13
  • 61
  • 137

0 Answers0