I have a little issue here, I want to get posts (json format) from Wordpress Rest API, and I do not understand what am I missing here. Can someone helps me?
var App = new Vue({
el : '#app',
data: {
posts: ''
},
beforeCreate: function(){
console.log('I am the first one!');
},
mounted: function(){
console.log('mounted fired');
posts = this.$resource('http://volkov.co.il/wp-json/wp/v2/posts?per_page=3');
posts.get(function(response){
this.$set('posts', response);
});
}});
And here is my html:
<div id="app">
<div class="row">
<div class="large-12 columns">
<article class="post-article" v-for="post in posts">
<h1>post title</h1>
<h3>{{ post.id }}</h3>
</article>
</div>
</div>
</div>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-resource/1.3.4/vue-resource.js"></script>
<script src="js/app.js" charset="utf-8"></script>
As you can see I am using vue-resource library. I am running this code from local machine. What am I missing here? Thanks