Coder Social home page Coder Social logo

use-the-force's Introduction

Use the Force

Objective

Use your knowledge of HTTP requests and XHR to get star wars film information from an API and render to the DOM.

Prerequisites

  • Basic knowledge of HTTP requests.
  • Basic understanding of API's.
  • Basic understanding of JSON.

Setup

  • Fork Repo
  • Clone repo to local machine.
  • Link up index.html and app.js

Your Challenge

Make a GET request using XHR to each endpoint. Grab and append the respective values requested onto the DOM.

Make a request to Star Wars API Endpoint

  • Create a new XHR object
var oReq = new XMLHttpRequest();
  • Declare a function to be used as the event listener.
function reqListener () {
  console.log(this.responseText);
}
  • Attach the event listener to an event
oReq.addEventListener("load", reqListener);
  • Set the destination and send the request!
oReq.open("GET", "http://www.google.com");
oReq.send();
  • The code
function reqListener () {
  console.log(this.responseText);
}

var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "http://www.example.com/api");
oReq.send();

Render the following on the DOM

  • People

    • Luke Skywalker
      • Height
      • Mass
      • Birth year
      • Gender
    • Leah
      • Height
      • Mass
      • Birth year
      • Gender
    • Darth Vader
      • Height
      • Mass
      • Birth year
      • Gender
  • Planets

    • Alderaan
    • Yavin IV
    • Hoth
    • Dagobah
    • Bespin
    • Endor
    • Naboo
    • Coruscant
    • Kamino
    • Geonosis
  • Films

    • A New Hope
      • Episode ID
      • Director
    • Attack of the Clones
      • Episode ID
      • Director
    • The Phantom Menace
      • Episode ID
      • Director
    • Revenge of the Sith
      • Episode ID
      • Director
    • Return of the Jedi
      • Episode ID
      • Director
    • The Empire Strikes Back
      • Episode ID
      • Director
    • The Force Awakens
      • Episode ID
      • Director

Resources

SWAPI

Using XMLHttpRequest - Web APIs | MDN

HTML DOM createElement() Method

HTML DOM appendChild() Method

use-the-force's People

Contributors

jaygiang avatar aasoma avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.