embedFromString: function(url, mediaType) {
let img = new Image,
canvas = document.createElement("canvas"),
ctx = canvas.getContext("2d"),
src = url;
let imgBase64;
img.crossOrigin = "Anonymous";
img.src = src;
return new Promise(((resolve, reject) => {
img.onload = async function() {
canvas.width = img.width;
canvas.height = img.height;
ctx.drawImage(img, 0, 0);
imgBase64 = canvas.toDataURL("image/png");
console.log(imgBase64, 'hello');
this.mediaType = mediaType;
this.url = imgBase64.split(',')[1];
this.base64 = true;
return resolve();
}
}));
}
In this function, this.mediaType / this.url/ this.base64 are not updated with new values. Even though updated values are in mediaType / imgBase64 / base64 respectively. How to set these updated value with "this"