mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
remove a log message about fetching URLs (#643)
Every fetch made from the client is logged to the console. But this isn't really necessary, and is particularly confusing in grist-static, where those fetches are virtualized. Tests in grist-saas may need adjusting to remove the logger.
This commit is contained in:
@@ -2,13 +2,10 @@ import {ApiError, ApiErrorDetails} from 'app/common/ApiError';
|
||||
import axios, {AxiosRequestConfig, AxiosResponse} from 'axios';
|
||||
import {tbind} from './tbind';
|
||||
|
||||
export type ILogger = Pick<Console, 'log'|'debug'|'info'|'warn'|'error'>;
|
||||
|
||||
export interface IOptions {
|
||||
headers?: Record<string, string>;
|
||||
fetch?: typeof fetch;
|
||||
newFormData?: () => FormData; // constructor for FormData depends on platform.
|
||||
logger?: ILogger;
|
||||
extraParameters?: Map<string, string>; // if set, add query parameters to requests.
|
||||
}
|
||||
|
||||
@@ -54,13 +51,11 @@ export class BaseAPI {
|
||||
protected fetch: typeof fetch;
|
||||
protected newFormData: () => FormData;
|
||||
private _headers: Record<string, string>;
|
||||
private _logger: ILogger;
|
||||
private _extraParameters?: Map<string, string>;
|
||||
|
||||
constructor(options: IOptions = {}) {
|
||||
this.fetch = options.fetch || tbind(window.fetch, window);
|
||||
this.newFormData = options.newFormData || (() => new FormData());
|
||||
this._logger = options.logger || console;
|
||||
this._headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
@@ -116,7 +111,6 @@ export class BaseAPI {
|
||||
}
|
||||
}
|
||||
const resp = await this.fetch(input, init);
|
||||
this._logger.log("Fetched", input);
|
||||
if (resp.status !== 200) {
|
||||
const body = await resp.json().catch(() => ({}));
|
||||
throwApiError(input, resp, body);
|
||||
|
||||
Reference in New Issue
Block a user