diff --git a/web/app/common/api.ts b/web/app/common/api.ts index 68133ad0..dbe1b960 100644 --- a/web/app/common/api.ts +++ b/web/app/common/api.ts @@ -133,6 +133,7 @@ export const getUser = (): Promise => .get({ url: '/user', withCredentials: true, + logError: false, }) .catch(() => null); diff --git a/web/app/common/fetcher.ts b/web/app/common/fetcher.ts index 908bdd04..685467e7 100644 --- a/web/app/common/fetcher.ts +++ b/web/app/common/fetcher.ts @@ -10,6 +10,8 @@ interface FetcherInitBase { url: string; overriddenApiBase?: string; withCredentials?: boolean; + /** whether log error message to console */ + logError?: boolean; } interface FetcherInitJSON extends FetcherInitBase { @@ -34,6 +36,7 @@ const fetcher = methods.reduce>((acc, method) => { withCredentials = false, overriddenApiBase = API_BASE, contentType = 'application/json', + logError = true, } = typeof data === 'string' ? { url: data } : data; const basename = `${BASE_URL}${overriddenApiBase}`; @@ -81,8 +84,10 @@ const fetcher = methods.reduce>((acc, method) => { try { err = JSON.parse(text); } catch (e) { - // eslint-disable-next-line no-console - console.error(err); + if (logError) { + // eslint-disable-next-line no-console + console.error(err); + } throw 'Something went wrong.'; } throw err;