I did not found answer. The same problem is How to convert file to base64 in JavaScript?.
previewPhoto (photo, id) {
const preview = document.getElementById(id)
const reader = new FileReader()
reader.onloadend = function () {
preview.src = reader.result
}
reader.readAsDataURL(photo)
},
There I just replace the src value in element by querySelector. But in may case I need something like this:
previewPhoto (photo) {
const readyToSrcImg = fileToImg(photo)
return readyToSrcImg
},
Does anyone know about this case?