samedi 3 juin 2017

TypeError: Cannot set property 'posts' of undefined - Vuejs

I create SPA with VueJs and Laravel. Homepage i get all posts via api laravel and axio resposive had data object. But i can not update to posts property.

My code in Wellcome.vue

import { mapGetters } from 'vuex'
import axios from 'axios'
export default {
  name: 'welcome',

  layout: 'default',

  metaInfo: { titleTemplate: 'Welcome | %s' },

  computed: mapGetters({
    authenticated: 'authCheck'
  }),

  data: () => ({
    title: 'Demo Blog',
  }),
  props: {
      posts: {
        type: Object
      }
  },
  created () {
    axios.get('/api/posts')
    .then(function (response) {
      this.posts = response.data;
    })
    .catch(function (error) {
      console.log(error);
    });
  },
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2qM27hh
via IFTTT

Aucun commentaire:

Enregistrer un commentaire