moringaman
2/24/2018 - 9:58 PM

NUXT - nuxtServerInit

    nuxtServerInit(vuexContext, context) {
                   return axios.get('https://nuxt-blog-1bae3.firebaseio.com/posts.json')
                   .then(res => {
                      const postsArray = []
                      for (const key in res.data) {
                        postsArray.push({...res.data[key], id: key})
                      }
                      vuexContext.commit('setPosts', postsArray)
                   })
                   .catch(e => context.error(e))
            }