[Vuejs]-Get data using asyncData

0👍

I’d remove your ‘category’ from your regular data. What I think is happening is your asyncData function works fine on the server side but when the component is mounted the regular data then sets ‘category’ to null. Try this:

export default {
  data () {
    return {

    }
  },
  asyncData() {
    return axios.get('/category')
    .then((res) => {
      return {category: res.data}
    })
  }
}

Leave a comment