Skip to content

Instantly share code, notes, and snippets.

@nirazul
Last active May 5, 2017 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nirazul/9c25dd02d237c123d5915d248189dc47 to your computer and use it in GitHub Desktop.
Save nirazul/9c25dd02d237c123d5915d248189dc47 to your computer and use it in GitHub Desktop.
blog.dreipol.ch - Snippet 7
export default {
beforeRouteEnter(to, from, next) {
const Fetched = to.meta.api.fetch(to.params, to.query);
next(vm => Fetched.then((vm) => {
vm.$set(vm, 'routeData', fetched);
});
},
beforeRouteUpdate(to, from, next) {
const Fetched = to.meta.api.fetch(to.params, to.query);
Fetched.then(() => {
this.$set(this, 'routeData', fetched);
});
next();
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment