4👍
✅
asyncData
is passed an argument called context, which has a corresponding type in @nuxt/types
called Context
. Import Context
from @nuxt/types
then declare the type of the destructured argument like this:
async asyncData({ $axios } : Context) {
const ip = await $axios.get('http://icanhazip.com')
return { ip }
}
Source:stackexchange.com