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

Browsersync Server is your little development friend 08th January, 2018

maybe-rgba() sass function 16th December, 2017

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

https://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.

Navigation