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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.