Skip to content

Instantly share code, notes, and snippets.

@mercs600
Last active March 28, 2020 15:22
Show Gist options
  • Save mercs600/b2ee57939523b42b96a7c2f60e28ecf4 to your computer and use it in GitHub Desktop.
Save mercs600/b2ee57939523b42b96a7c2f60e28ecf4 to your computer and use it in GitHub Desktop.
nuxt-ssr-exercise-3_index
<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