From f9753b69971161b6d3b806ebe4757c61479a63fd Mon Sep 17 00:00:00 2001 From: Niek Candaele Date: Sun, 5 Jan 2025 14:58:26 +0100 Subject: [PATCH] feat: more details about requests happening inside a module --- packages/lib-apiclient/src/lib/baseClient.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/lib-apiclient/src/lib/baseClient.ts b/packages/lib-apiclient/src/lib/baseClient.ts index 02bfcb6e97..cedf5857b5 100644 --- a/packages/lib-apiclient/src/lib/baseClient.ts +++ b/packages/lib-apiclient/src/lib/baseClient.ts @@ -54,9 +54,20 @@ export class BaseApiClient { } axios.interceptors.request.use((request) => { + let prettyBody = null; + + if (request.data) { + try { + prettyBody = JSON.parse(request.data); + } catch { + prettyBody = 'Could not parse body'; + } + } + this.log.info(`➡️ ${request.method?.toUpperCase()} ${request.url}`, { method: request.method, url: request.url, + body: prettyBody ?? undefined, }); return request; });