I have this javascript code. I am converting blob to base64 here. The reader.onloadend function when called starts processing asynchronously. So console(reader.result) which should print after the function, prints before the function completion and gives wrong value(value before the change in function). I want to use the changed value of reader.result after completion of async onload function.
var reader = new window.FileReader();
reader.readAsDataURL(array);
reader.onloadend = kk=function() {
base64data = reader.result;
//console.log(base64data );
//document.write(base64data);
//document.getElementById('display1').setAttribute('src',base64data);
return base64data
}
console(reader.result)