Load Locations/People/Vehicles from layout on app load

This commit is contained in:
2020-12-21 22:06:36 +01:00
parent 5bab5b2041
commit 2e35d86e1a
3 changed files with 42 additions and 5 deletions

View File

@@ -10,7 +10,16 @@
<script>
export default {
middleware: ["redirect"]
middleware: ["redirect"],
fetchOnServer: false,
async fetch() {
const { store } = this.$nuxt.context;
if (!store.state.people.list.length) await store.dispatch("people/getList");
if (!store.state.vehicles.list.length)
await store.dispatch("vehicles/getList");
if (!store.state.locations.list.length)
await store.dispatch("locations/getList");
}
};
</script>