This Lesson is for Members

Subscribe today and get access to all lessons! Plus direct HD download for offline use, enhances transcripts, member comment forums, and iTunes "podcast" RSS feed. Level up your skills now!

Unlock This Lesson

Already subscribed? Sign In

Autoplay

    Review final screencast result

    Trevor MillerTrevor Miller

    Our lesson has been planned, recorded, and edited. It’s ready to be uploaded to egghead.io! Victory dance. Let’s see how it all turned out.

    Code

    Code

    Become a Member to view code

    You must be a 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
    Transcript

    Transcript

    00:00 We're ready to upload our lesson to egghead.io. Let's see what the finished product looks like. First let's type consturl, and let's set that equal to the GitHub API, so that's api.github.com/users, and then we need some sort of user here. Now let's type constuser = some GitHub user name, which if we use mine, that's TrevorDMiller.

    00:24 Now we can use the global fetch function by saying fetch and then passing it our URL. This function will return a promise, so we can say .then and when this promise resolves, it will contain our response. We'll say response, and now inside of this function we can say response.json to convert our response into JSON.

    00:45 Now let's type .then, we'll have our JSON data. Let's console log out the type of the GitHub account. We see we have the type of user, because the TrevorDMiller GitHub account is of type user. If we go back up to our user string here and use Facebook, we now see that Facebook is of type organization.

    01:07 Now let's go down and type .catch and this will be used if we get an error. We will get our error, and we can use that error. Let's just log out the error in this case. Let me turn off my network connection. Now we get this type error, failed to fetch.

    Discuss

    Discuss