Julien Melissas

This is how easy it is to get data from the WP-API

Introduction

Julien Melissas

Julien Melissas

I'm a Web Developer, Foodie, and Music Lover/Maker living in Asheville, NC. I make things on the web at Craftpeak & JM Labs.


LATEST POSTS

Nomading 2016: Days 10 & 11 – Portuguese Craft Beer/London Bound 30th December, 2016

Nomading 2016: Days 8 & 9 – Motorcycle Trip 23rd December, 2016

Code

This is how easy it is to get data from the WP-API

Posted on .

So I was at a #WCAVL planning meeting today and was trying to come up with a talk idea, and noticed we haven’t had many JS submissions. I thought: “oh hey – maybe it’d be cool for me to do one comparing using the WP-API with React, Angular, Backbone, etc…” Someone said: “there’s no way you could fit that into one session.” I’m like “Watch me.”

SO anyways I dared myself to get posts from the WP-API with Angular in “less than 5 minutes.” Not too hard:

0

 

Also here’s an example comparing it to how it might work in React:

0

 

Update 1: Some co-working space friend asked for the React example without jQuery:

0

 

Update 2: I felt like I should leave a Backbone example here, cause WP ships with it and all…

0

(BTW I’m really not great at Backbone and I feel like my PostsView could probably listen to model changes and then update it’s view and that would be better, but I didn’t know best practice for that)

 

By no means are these the “best way” to do anything or even super thought-through. But they work, and they’re ezpz, and it helps illustrate how easy it is to grab stuff with the WP-API.

Julien Melissas

Julien Melissas

http://www.julienmelissas.com

I'm a Web Developer, Foodie, and Music Lover/Maker living in Asheville, NC. I make things on the web at Craftpeak & JM Labs.

View Comments (0) ...
Navigation