Skip to content

Instantly share code, notes, and snippets.

@mercs600
Created March 31, 2020 12:36
Show Gist options
  • Select an option

  • Save mercs600/486cf2d552d9ef145f089927d5bcd015 to your computer and use it in GitHub Desktop.

Select an option

Save mercs600/486cf2d552d9ef145f089927d5bcd015 to your computer and use it in GitHub Desktop.
nuxt-exercise-5-fetch-blog-id.vue
<template>
<div v-if="post">
<h1>{{ post.title }}</h1>
<div>{{ post.body }}</div>
<nuxt-link to="/fetch-blog">back to list</nuxt-link>
</div>
</template>
<script>
export default {
data () {
return {
post: null
}
},
async fetch () {
this.post = await this.$http
.$get(`https://jsonplaceholder.typicode.com/posts/${this.$route.params.id}`)
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment