hubspy
Version:
A package to extract github metadata and total contributions for a github user.
23 lines (22 loc) • 1.12 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
export default function fetchGithubUserMetadata(name) {
return __awaiter(this, void 0, void 0, function* () {
const data = yield fetch(`https://api.github.com/users/${name}`);
if (!data.ok) {
console.error(`Failed to fetch Github metadata for ${name} ${data.status}`);
return;
}
else {
const json = yield data.json();
return json;
}
});
}