Last active
March 28, 2020 15:22
-
-
Save mercs600/b2ee57939523b42b96a7c2f60e28ecf4 to your computer and use it in GitHub Desktop.
nuxt-ssr-exercise-3_index
This file contains 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> | |
<h1> Blog posts </h1> | |
<div v-if="posts && posts.length"> | |
<div | |
v-for="post in posts" | |
:key="post.id"> | |
<nuxt-link :to="`/asyncData-blog/${post.id}`">{{ post.title }}</nuxt-link> | |
</div> | |
</div> | |
</div> | |
</template> | |
<script> | |
export default { | |
async asyncData({ $http }) { | |
const posts = await $http.$get(`https://jsonplaceholder.typicode.com/posts`) | |
return { | |
posts | |
} | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment