moringaman
2/24/2018 - 11:52 PM

NUXT asyncData Call

This call loads data returned by a promise and renderes the data on the server - for use in vue template

  asyncData(context, callback) {
        setTimeout(()=>{
            callback(null, {
                loadedPosts: [
                        {id: '1', title: 'First Post', previewText: "this is the very first post",
         thumbnail: "http://piotrpasich.com/wp-content/uploads/2017/10/crypto.jpg"},
         {id: '2', title: 'Secound Post', previewText: "this is the second post post",
          thumbnail: "http://piotrpasich.com/wp-content/uploads/2017/10/crypto.jpg"}
                ]
            })
        }, 3000)
    }