VueJsWordpress Hooks

Vuejs api to get wordrpess data

Vuejs api to get wordrpess data

Vue js with laravel 5.7
2.27KViews

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

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

Positive SSL