I have the following code
It returns a string when in the reader.onload function but null when i console.log image.Url in the outer function
EDIT: This is the full code
export default {
data() {
return {
item: {
image: null
},
imageUrl: null,
};
},
methods: {,
uploadImage(e) {
let image = e.target.files[0];
const reader = new FileReader();
reader.readAsDataURL(image);
reader.onload = function(){
this.imageUrl = reader.result
console.log(this.imageUrl)
// this.setImageOne(this.imageUrl)
}
console.log(this.imageUrl)
},
EDIT:
Fixed it. Thanks everyone