Skip to content

Instantly share code, notes, and snippets.

@Akryum

Akryum/App.vue

Last active Sep 30, 2019
Embed
What would you like to do?
<template>
<div id="app">
<RouteController />
<nav>...</nav>
<router-view/>
</div>
</template>
<script>
export default {
apollo: {
user: {
// ...
}
},
async onBeforeEachRoute (to, from, next) {
await this.$apollo.firstLoad
if (this.user) {
}
next()
}
}
</script>
export function createRouter (apolloProvider) {
const router = new Router()
router.beforeEach(async (to, from, next) => {
const { data: { user } } = await apolloProvider.clients.default.query({
// ...
})
if (user) {
}
next()
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment