- If I run this to retrieve an image and encode it for storage in a stand alone function - works perfectly to create data:image/png;base64.
- Running exactly the same function in ionic vue creates data:text/html;base64, the data for which refers to some type of ionic html doc and not the image.
- What am I missing here because being new to ionic vue i am not understanding the architecture or something. I’ve read and jsfiddled/ionic served thru everything I can find for 3 days without success. I do not want to use the input=file to get the image, I wish to assign an image.
function retrieveFile() {
file = ‘blank.person.png’;
var xhr = new XMLHttpRequest();
xhr.open('GET', file, true);
xhr.responseType = 'blob';
xhr.onload = function() {
if (this.status == 200) {
var reader = new FileReader();
reader.readAsDataURL(this.response);
reader.onload = function () {
var base64String = reader.result;
}
}
};
xhr.send();
}