O'Reilly logo

Vue.js 2.x by Example by Mike Street

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required