Caching the folder contents

Now that we have Vuex in our app and are utilizing it for the path, we can begin to look at storing the contents of the currently-displayed folder so that if the user returns to the same place, the API does not need to be queried to retrieve the results. We are going to do this by storing the object returned by the API the Vuex store.

When the folder gets requested, the app will check whether the data exists in the store. If it does, the API call will be omitted and the data loaded from the storage. If it doesn't exist, the API will be queried and the results saved in the Vuex store.

The first step is to separate out the data processing into its own method. This is because the files and folders are going to need ...

Get Vue.js 2.x by Example 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.