Skip to content

Instantly share code, notes, and snippets.

@MartinMalinda
Created July 4, 2020 12:54
Show Gist options
  • Save MartinMalinda/bf39ccb836c7ad7b77239d0427b5d935 to your computer and use it in GitHub Desktop.
Save MartinMalinda/bf39ccb836c7ad7b77239d0427b5d935 to your computer and use it in GitHub Desktop.
<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>
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