From 50a3df40bc8d41271c4cd8d6873a6d4e1dd87b42 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 20 Jan 2022 19:32:36 +0100 Subject: chore: add a project summary component --- src/services/repos/github.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/services/repos/github.ts (limited to 'src/services') diff --git a/src/services/repos/github.ts b/src/services/repos/github.ts new file mode 100644 index 0000000..37400ad --- /dev/null +++ b/src/services/repos/github.ts @@ -0,0 +1,15 @@ +import { RepoData } from '@ts/types/github'; + +/** + * Retrieve repository data from Github by slug. + * @param repo - The repository slug. + * @returns {Promise} - The repository data. + */ +export const getRepoData = async (repo: string): Promise => { + const user = process.env.NEXT_PUBLIC_GITHUB_USER; + const api = `https://api.github.com/repos/${user}/${repo}`; + + const response = await fetch(api); + + return response.json(); +}; -- cgit v1.2.3