Created
January 11, 2022 20:04
-
-
Save PatrickKalkman/5183a22336e61fd08aa4a43d0e7d27eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<h1>Dashboard</h1> | |
<template v-if="!isLoading"> | |
<CustomerCard | |
v-for="customer in customers" | |
:key="customer.id" | |
:customer="customer" | |
/> | |
</template> | |
<p v-else>Loading customers</p> | |
</div> | |
</template> | |
<script> | |
import CustomerCard from '@/components/CustomerCard'; | |
export default { | |
components: { CustomerCard }, | |
data() { | |
return { | |
isLoading: true, | |
customers: [], | |
}; | |
}, | |
created() { | |
this.$store | |
.dispatch('getCustomers') | |
.then(() => { | |
this.isLoading = false; | |
this.customers = this.$store.state.customers; | |
}) | |
.catch((err) => { | |
this.isLoading = false; | |
console.log(err); | |
}); | |
}, | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment