Skip to content

Instantly share code, notes, and snippets.

@stefanledin
Last active February 5, 2019 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanledin/45e0bcad8562b03c1cc6b9266e3d14ba to your computer and use it in GitHub Desktop.
Save stefanledin/45e0bcad8562b03c1cc6b9266e3d14ba to your computer and use it in GitHub Desktop.
<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