[Vuejs]-Nuxt – asyncData ERROR: "Binding element '$axios' implicitly has an 'any' type."

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 }
}

Leave a comment