Coder Social home page Coder Social logo

the-async-force-ep-2's Introduction

The-Async-Force-Ep-2

An async Exercise using client side XHR accessing the swapi API at https://swapi.co

Excercise

Remember to commit after each step.

  1. Make a /js folder and create an app.js file in it.

  2. In the index.html file, load app.js via script tags.

  3. Use live-server to serve up the files to your browser.

  4. Construct your XHR requests in the app.js file by scraping the value from the input field.

  5. A request to the SWAPI api should be initiated when the button is clicked. Information that comes back from the API should be displayed in the body of the html. Additional html elements should be created to properly parse, display and format the data in a presentable way.

  6. If a person is requested, display the following information: - Name, in an <h2> tag - Gender, in an <p> tag - Species (only get the first species if there are multiple) (only display the name), in an <p> tag

  7. If a planet is requested, display the following information: - Name, in an <h2> tag - Terrain, in an <p> tag - Population, in an <p> tag - a list of all Film names that this planet appeared in <li> tags wrapped in <ul>

  8. If a starship is requested, display the following information: - Name, in an <h2> tag - Manufacturer, in an <p> tag - Starship Class, in an <p> tag - a list of all Film names that this starship appeared in <li> tags wrapped in <ul>

  9. Display any xhr errors in the dom, so the user can see. For example, if a user inputs 99999 as an id, or potato. Display the error on the page.

Note: Go to https://swapi.co to preview the data that you will be requesting

Demo

demo

Hints

  1. URL Fragments are the parts of a URL that an API Endpoint parses to tell the server what resource to retrieve.
  2. Slides on Async HTTP Request with XHR: http://slides.com/sgnl/xhr#/
  3. Documentation on 'XMLHttpRequest' method: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest
  4. Remember that this is a client side excercise which means that all the code will be executed via the browser's javascript runtime, which means that our global context is the 'window' object. Go ahead and type in 'window' in the browser console to inspect the methods on the 'window' object. In there you will find a method named 'XMLHttpRequest' which you will be using for this excercise.

the-async-force-ep-2's People

Contributors

lorecrafting avatar theremix avatar

Watchers

 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.