Within a vue.js component, I have successfully received the value of web3. However, when attempting to use it in an async function, I am encountering an undefined error on the variable. Is there something missing or should it be possible to use it as shown below? (blockNum is already assigned a value earlier in the code.)
props: ['web3']
async function getTimestamp () {
const block = await this.web3.eth.getBlock(blockNum)
const ts = await this.web3.eth.getBlock(block).timestamp
return ts
}
console.log(getTimestamp())