Created
July 4, 2020 12:54
-
-
Save MartinMalinda/bf39ccb836c7ad7b77239d0427b5d935 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> | |
<div v-if="getUsersTask.isRunning"> Loading ... </div> | |
<div v-else-if="getUsersTask.isError"> {{ getUsersTask.last.error }} </div> | |
<div v-else v-for="user in getUsersTask.last.value"> | |
{{ user.name }} | |
</div> | |
</div> | |
</template> |
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 getUsersTask = useTask(function * () { | |
const response = yield axios('/api/users'); | |
return response.data.users; | |
}); | |
getUsersTask.perform(); | |
return { getUsersTask }; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment