• Hello
  • resume
  • Ships
  • Snippets
  • Hello
  • resume
  • Ships
  • Snippets
elijah@elijahcobb.com

    Fetch a GitHub user's info using the REST API

    Open Gist
    TypeScript
    1
    8 months ago
    github-user.ts
    TypeScript
    1const username = "elijahjcobb";
    2fetch(`https://api.github.com/users/${username}`)
    3  .then(res => res.json())
    4  .then(gist => {
    5    const {name, company, location} = gist;
    6    console.log(`${name} works at ${company} in ${location}.`);
    7  });

    Fetch a single gist from GitHub's REST API

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