Your problem here extends from the definition for await…
The
awaitoperator is used to wait for aPromise
The Image.prototype.onload property is not a promise, nor are you assigning it one. If you’re wanting to return the height property after loading, I would instead create a Promise…
addImageProcess(src){
return new Promise((resolve, reject) => {
let img = new Image()
img.onload = () => resolve(img.height)
img.onerror = reject
img.src = src
})
}
You would then use the following to access that value
tmp.addImageProcess(imageUrl).then(height => {
console.log(height)
})
or, if within an async function
async function logImageHeight(imageUrl) {
console.log('height', await tmp.addImageProcess(imageUrl))
}