Only storing new data

As mentioned earlier, the current createFolderStructure method both displays the structure and caches the response in the store, thus re-saving the structure even when the data is loaded from the cache.

Create a new method that the Dropbox API will fire once the data has loaded. Call it createStructureAndSave. This should accept the response variable as its only parameter:

createStructureAndSave(response) {  }

We can now move the store commit function from the createFolderStructure method into this new one, along with a call to fire the existing method with the data:

createStructureAndSave(response) {    this.createFolderStructure(response)    this.$store.commit('structure', {    path: this.slug,    data: response  });}

Lastly, ...

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.