Categories

Friday, April 26, 2024
#919814419350 therichposts@gmail.com
VueJsWordpress Hooks

Vuejs api to get wordrpess data

Vuejs api to get wordrpess data

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

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

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