I'm not sure why the following function returns a promise, when I'm using the async
/await
operators?
getBase64 = async (url) => {
const response = await axios.get(url, {
responseType: 'arraybuffer'
})
const buffer = new Buffer.from(response.data,'binary').toString('base64')
return ('data:image/jpeg;base64,' + buffer)
}
I know I can simply add .then(data => console.log(data))
but I want to assign the raw data to a variable, like:
const base64Img = getBase64()
...which is not possible since the return type is a promise for some reason.