Skip to content

Instantly share code, notes, and snippets.

View elijahjcobb's full-sized avatar

Elijah Cobb elijahjcobb

View GitHub Profile
@elijahjcobb
elijahjcobb / github-user.ts
Last active July 22, 2022 16:29
Fetch a GitHub user's info using the REST API
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}.`);
});
@elijahjcobb
elijahjcobb / gist.ts
Last active July 22, 2022 05:59
Fetch a single gist from GitHub's REST API
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}!`);
});