Created
July 6, 2020 14:42
-
-
Save MartinMalinda/c5507cdb43c24c82c857e8fc208d6ad3 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
export default defineComponent({ | |
setup() { | |
const store = useStore(); | |
const { data, error, isLoading, run: fetchUsers } = useAsync(async () => { | |
if (store.getters.hasUsers) { | |
return store.getters.users; | |
} | |
const response = await axios('/api/users'); | |
const users = normalizeFindUsersResponse(response); | |
store.commit('setUsers', users); | |
return users; | |
}); | |
return { data, error, isLoading, fetchUsers }; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment