Created
March 31, 2020 12:36
-
-
Save mercs600/486cf2d552d9ef145f089927d5bcd015 to your computer and use it in GitHub Desktop.
nuxt-exercise-5-fetch-blog-id.vue
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 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