• hello
  • resume
  • blog
  • guests
  • ships
  • snippets
  • hello
  • resume
  • blog
  • ships
  • snippets
elijah@elijahcobb.com

    Fetch a GitHub user's info using the REST API

    Open Gist
    TypeScript
    1
    over 1 year ago
    const username = "elijahjcobb";
    fetch(`https://api.github.com/users/${username}`)
      .then(res => res.json())
      .then(gist => {
        const {name, company, location} = gist;
        console.log(`${name} works at ${company} in ${location}.`);
      });

    Fetch a single gist from GitHub's REST API

    Open Gist
    TypeScript
    1
    over 1 year ago
    const id = "<the-gist-id>";
    fetch(`https://api.github.com/gists/${id}`)
      .then(res => res.json())
      .then(gist => {
        const {createdAt, description} = gist;
        console.log(`The ${description} gist was created at ${createdAt}!`);
      });
elijah@elijahcobb.com