diff options
Diffstat (limited to 'source/github-helpers/api.ts')
-rw-r--r-- | source/github-helpers/api.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/github-helpers/api.ts b/source/github-helpers/api.ts index 386156ac..45860893 100644 --- a/source/github-helpers/api.ts +++ b/source/github-helpers/api.ts @@ -48,6 +48,13 @@ interface RestResponse extends AnyObject { ok: boolean; } +export async function log(message: string): Promise<void> { + const {logAPI} = (await optionsStorage.getAll()); + if (logAPI) { + console.log(message); + } +} + export const escapeKey = (value: string | number): string => '_' + String(value).replace(/[ ./-]/g, '_'); export class RefinedGitHubAPIError extends Error { @@ -118,6 +125,7 @@ export const v3 = mem(async ( } const url = new URL(query, api3); + void log(String(url)); const response = await fetch(url.href, { method, body: body && JSON.stringify(body), @@ -174,6 +182,10 @@ export const v4 = mem(async ( query = query.replace('repository() {', () => `repository(owner: "${getRepo()!.owner}", name: "${getRepo()!.name}") {`); + void log(`{ + ${query} + }`); + const response = await fetch(api4, { headers: { 'User-Agent': 'Refined GitHub', |