diff options
author | 2021-08-22 07:43:21 +0300 | |
---|---|---|
committer | 2021-08-22 11:43:21 +0700 | |
commit | 5d9f32209094be67aa12d906fc727e6f729e9119 (patch) | |
tree | 51ecc810b3dcb1ad60945cdd382082c2d8d93ab6 /source/github-helpers/api.ts | |
parent | 751c977d91315d3fcaab919523dd4eb05a1667d0 (diff) | |
download | refined-github-5d9f32209094be67aa12d906fc727e6f729e9119.tar.gz refined-github-5d9f32209094be67aa12d906fc727e6f729e9119.tar.zst refined-github-5d9f32209094be67aa12d906fc727e6f729e9119.zip |
Meta: Make `Log API calls in the console` option checkbox visible (#4667)
Co-authored-by: Yakov <16872793+yakov116@users.noreply.github.com>
Diffstat (limited to 'source/github-helpers/api.ts')
-rw-r--r-- | source/github-helpers/api.ts | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/source/github-helpers/api.ts b/source/github-helpers/api.ts index 45860893..17937968 100644 --- a/source/github-helpers/api.ts +++ b/source/github-helpers/api.ts @@ -29,6 +29,7 @@ import mem from 'mem'; import * as pageDetect from 'github-url-detection'; import {JsonObject, AsyncReturnType} from 'type-fest'; +import features from '../features'; import {getRepo} from '.'; import optionsStorage from '../options-storage'; @@ -48,13 +49,6 @@ 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 { @@ -125,7 +119,7 @@ export const v3 = mem(async ( } const url = new URL(query, api3); - void log(String(url)); + features.log.http(url); const response = await fetch(url.href, { method, body: body && JSON.stringify(body), @@ -182,7 +176,7 @@ export const v4 = mem(async ( query = query.replace('repository() {', () => `repository(owner: "${getRepo()!.owner}", name: "${getRepo()!.name}") {`); - void log(`{ + features.log.http(`{ ${query} }`); |