Giter Site home page Giter Site logo

js-apis-lab-web-121117's Introduction

GitHub API

Objectives

  • Use Ajax to make a get request to an API
  • Use Ajax to make a post request to an API
  • Parse JSON to get clean API data

Intro

For this lab we will be using the GitHub API to create and view Gists. In this lab you will create a UI that allows users to see a list of their gists and be able to create new ones.

Instructions

You will need to visit Github Tokens and create a personal token to use. This token allows you to request data for your account. Make sure you select "gists" from the checkboxes to allow your token to have access to that part of the Github API. Also, before you begin, visit list a gist guide and create a gist guide and review how to use the gist portion of the GitHub API.

  • Create the method myGists(username, token) that returns the gists for a user.
  • Create the method createGist(file_name, content, description, token) that creates a public gist.
  • Create the method bindCreateButton that will bind the click event for the button that makes our request.

Note: To get the tests to pass, do not use any ES6 syntax (that includes string interpolation ${}, arrow function =>, const, let, ...)

User Interface

With your code ready to go, create the UI.

  • Create a form for the user to enter
    • Personal token.
    • Gist file name.
    • Gist description.
    • Gist contents.
  • Have a button that when clicked
    • Creates a public gist for a user.
    • Updates the UI to show the list of public gists for the user.
      • Use the html_url for the href and the description from the gist as the link text.

Hint

The GitHub API requires you to send a token as part of the request headers. This token will be the personal token you created in the beginning of the lab. To set the headers, you can pass the options that you need to the headers field in your request options. An example is below:

$.ajax({
  url: 'GITHUB_URL_HERE',
  type: 'POST',
  dataType: 'json',
  headers: {
    Authorization: "token YOUR_TOKEN_HERE"
  }
})

References

View Github API Lab on Learn.co and start learning to code for free.

js-apis-lab-web-121117's People

Contributors

victhevenot avatar cbdileo avatar pletcher avatar annjohn avatar thelucasmoore avatar

Watchers

 avatar Rishikesh Tirumala avatar James Cloos avatar  avatar  avatar  avatar Joe Cardarelli avatar Sara Tibbetts avatar The Learn Team avatar Cernan Bernardo avatar Sophie DeBenedetto avatar  avatar Antoin avatar  avatar  avatar Nicole Kroese  avatar Lisa Jiang avatar  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.