[Vuejs]-How can I use the async function for my head object in Vue js?

0👍

Both the head() and asyncData() properties are not part of the core of vue,

  • to use head() you need to install this as a plugin
  • to use asyncData() you have to use nuxt

If your spa has a strong need for seo I suggest you use nuxt, which natively includes seo and the conversion from vue to nuxt is very easy

If you already using nuxt this is the correct way to get

async asyncData({params: any }) { 
 const articlelist = await axios.get('some.url'); //get the data
 return { articlelist }; //this object is merged with the data of the istance

}

Leave a comment