Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Stream an API using RxJS into a Vue.js Template

    5.5.12 - 6.4.0

    You can map remote data directly into your Vue.js templates using RxJS. This lesson uses axios (and the vue-axios library which exposes axios on components as this.$http) and wraps the remote call inside of an Observable to provide the data into the template



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Instructor: I'm also going to install axios, and vue-axios. I can figure these by importing axios from axios, and importing vue-axios from vue-axios, and telling vue to use vue-axios and provide axios.

    This simply gives me on my components and HTTP servers to make the request that I need. Let me start with a stream called people, and say this is observable from this.HTTP, $HTTP and get, and the data I want to get is

    All I have to do is add this people to a returned value here that I can render out people. It save, and you'll see the response is all of this, and what I really want off of this is the data, I can tell my stream to pluck the data off the response. It save, and you can see the data we have here.

    Since what I really want is this name, I can do a comma name, it save and you'll see Luke Skywalker. That's all from the stream observable from, and this is just axios, which is like fetch with a lot more features, this is returning a promise, we're wrapping the promise within observable, plucking the data may be off of it.

    Then, we're passing this in to the return object, then simply rendering it up.