Home VueJs Vuejs api to get wordrpess data

Vuejs api to get wordrpess data

by therichpost
0 comment
Vue js with laravel 5.7

Hello to all, welcome to therichpost.com. In this post, I will tell you how to make Vuejs api to get wordrpess data ? I really like these kind of post and I did same in my last post with Angularjs
Angularjs 2 services with wordpress rest api. I can say Vue Js is the good competitor of Angularjs. I must say Vuejs code is simple and clean.

First please check the wordpress api result get user data:

Here you can check the code for How to get all users in wordpress with rest api hook?

Now this wordpress data, we will get in our vuejs application.

Here is the Vuejs code to get wordpress data:

<div id=”app”>
<ul>
<li v-for=”user in users”>
{{ user }}
</li>
</ul>
</div>
<script src=”https://cdn.jsdelivr.net/npm/vue”></script>
<script>
var app = new Vue({
el: ‘#app’,
data: {
users: []
},
created () {
fetch(“http://localhost/cfood4u/wp-json/wp/v2/getusers”)
.then(response => response.json())
.then(json =>{
this.users = json
console.log(this.users);
})
}
})
</script>

There are so many tricky code in VueJs and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

You may also like

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.