Fetching remote data

We have a problem--each component using our RemoteData mixin will have different data properties to fetch. Therefore, we need to pass parameters to our mixin. Since a mixin is essentially a definition object, why not use a function that can take parameters and then return a definition object? That's what we will do in our case!

  1. Wrap the object we have defined inside a function with a resources parameter:
      export default function (resources) {        return {          data () {            return {              remoteDataLoading: 0,            }          },        }      }

The resources parameter will be an object with each key being the name of the data property we want to add, and the value being the path of the request that needs to be made to the server.

  1. So we need to change the way ...

Get Vue.js 2 Web Development Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.