Skip to content

Instantly share code, notes, and snippets.

@mercs600
Created April 4, 2020 14:51
Show Gist options
  • Save mercs600/8bddf62059a0cd92bc9fd23d91b4ec69 to your computer and use it in GitHub Desktop.
Save mercs600/8bddf62059a0cd92bc9fd23d91b4ec69 to your computer and use it in GitHub Desktop.
nuxt-exercise-5-author
<template>
<div>
<div v-if="$fetchState.pending">
<content-placeholders-text :lines="1" />
</div>
<div v-else-if="author">
<p>{{ author.name }} / {{ author.email }}</p>
</div>
</div>
</template>
<script>
export default {
props: {
authorId: {
type: Number,
required: true
}
},
data () {
return {
author: null
}
},
async fetch () {
if (this.authorId) {
this.author = await this.$http
.$get(`https://jsonplaceholder.typicode.com/users/${this.authorId}`)
}
},
fetchOnServer: false
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment