MCPcopy Index your code
hub / github.com/refined-github/refined-github / baseApiFetch

Function baseApiFetch

source/github-helpers/github-token.ts:14–37  ·  view source on GitHub ↗
({apiBase, token, path}: BaseApiFetchOptions)

Source from the content-addressed store, hash-verified

12};
13
14export async function baseApiFetch({apiBase, token, path}: BaseApiFetchOptions): Promise<Response> {
15 if (!apiBase.endsWith('/')) {
16 throw new TypeError('apiBase must end with a slash');
17 }
18
19 const response = await fetch(
20 new URL(path, apiBase),
21 {
22 cache: 'no-store',
23 headers: {
24 'user-agent': 'Refined GitHub',
25 accept: 'application/vnd.github.v3+json',
26 authorization: `token ${token}`,
27 },
28 },
29 );
30
31 if (!response.ok) {
32 const details = await response.json();
33 throw new Error(details.message);
34 }
35
36 return response;
37}
38
39export const tokenUser = new CachedFunction('token-user', {
40 async updater(apiBase: string, token: string): Promise<string> {

Callers 4

updaterFunction · 0.85
hasValidGitHubComTokenFunction · 0.85
getTokenInfoFunction · 0.85
checkTokenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected