diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-20 19:32:36 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-20 19:32:36 +0100 |
| commit | 50a3df40bc8d41271c4cd8d6873a6d4e1dd87b42 (patch) | |
| tree | ee338cebabbcce5c53c417172b25367c00e19e17 /src/services | |
| parent | df9e8b1985a0f1c71c0657e72fad008bf437faba (diff) | |
chore: add a project summary component
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/repos/github.ts | 15 |
1 files changed, 15 insertions, 0 deletions
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<RepoData>} - The repository data. + */ +export const getRepoData = async (repo: string): Promise<RepoData> => { + 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(); +}; |
