Angular(2) – Base64 Image from URL [on hold]

Home / Uncategorized / Angular(2) – Base64 Image from URL [on hold]

I need to create a function that receives the URL of an image and returns that image in Base64.

I created the function:getBase64Image(url: string): Promise {
return this.http.get(url, {
headers: this.headers,
responseType: ResponseContentType.Blob
.then(res => {
let blob: Blob = new Blob([res.json()], {
type: res.headers.get("Content-Type")

var reader = new FileReader();
reader.onloadend = function(e){
base64 = reader.result;

My problem is on how to return Base64 (reader.result).

Here is an answer with example to get image from api and return it as base64.
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *