mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 22:25:12 +00:00
e934da3c36
Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Clark Du <clark.duxin@gmail.com>
31 lines
535 B
Vue
31 lines
535 B
Vue
<template>
|
|
<p v-if="$fetchState.error">
|
|
Could not fetch Author
|
|
</p>
|
|
<p v-else>
|
|
Written by {{ $fetchState.pending ? '...' : user.name }} <button @click="$fetch">
|
|
Refresh
|
|
</button>
|
|
</p>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
props: {
|
|
userId: {
|
|
type: Number,
|
|
required: true
|
|
}
|
|
},
|
|
data () {
|
|
return {
|
|
user: {}
|
|
}
|
|
},
|
|
async fetch () {
|
|
this.user = await this.$http.$get(`https://jsonplaceholder.typicode.com/users/${this.userId}`)
|
|
},
|
|
fetchOnServer: false
|
|
}
|
|
</script>
|