Last active
February 5, 2019 14:57
-
-
Save stefanledin/45e0bcad8562b03c1cc6b9266e3d14ba to your computer and use it in GitHub Desktop.
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> | |
<ul v-if="posts"> | |
<li v-for="post in posts" v-bind:key="post.id">{{ post.title }}</li> | |
</ul> | |
</div> | |
</template> | |
<script> | |
import axios from 'axios'; | |
export default { | |
props: ['category'], | |
async created() { | |
const posts = await axios.get(`/wp-json/wp/v2/posts?categories={$this.category}`) | |
if (posts.data) { | |
this.posts = posts.data; | |
} | |
}, | |
data() { | |
return { | |
posts: null | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment