function getBase64(imgUrl) {
return new Promise((resolve, reject) => {
try {
window.URL = window.URL || window.webkitURL;
var xhr = new XMLHttpRequest();
xhr.open('get', imgUrl, true);
xhr.responseType = 'blob';
xhr.onload = function () {
if (this.status == 200) {
var blob = this.response;
let oFileReader = new FileReader();
oFileReader.onloadend = function (e) {
let base64 = e.target.result;
resolve(base64);
};
oFileReader.readAsDataURL(blob);
}
};
xhr.onerror = function (err) {
reject(err.message);
};
xhr.send();
} catch (error) {
reject(error.message);
}
});
}
console