Skip to content

Instantly share code, notes, and snippets.

View manavm1990's full-sized avatar
🏠
Working from home

Manav Misra manavm1990

🏠
Working from home
View GitHub Profile
@manavm1990
manavm1990 / github-proxy-client.js
Created March 11, 2022 16:01 — forked from DavidWells/github-proxy-client.js
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
async function getRepo() {
// Create a new PROMISE
// This requires 2 PARAMETERS 'resolve' and 'reject'
const p = new Promise((resolve, reject) => {
// 'setTimeout' to simulate a 1s delay
setTimeout(() => resolve('done!'), 1000)
})
// DECLARE a new FUNCTION, 'f' as 'async' - need 'async' to use 'await'
// There are no PARAMETERS
async function f() {