From 30d0d3cdafdcf186f581cd602da95b66c84d024f Mon Sep 17 00:00:00 2001 From: Bertrand Marron Date: Tue, 3 May 2022 08:00:31 +0200 Subject: [PATCH] fix: make sure error.config is defined in the errorLogger MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes, axios throws an error without `error.config`, this makes sure we don’t destructure an undefined property. Related: https://github.com/axios/axios/pull/4665 Fix #94 --- src/logger/error.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/logger/error.ts b/src/logger/error.ts index a4a03a3..9503dbc 100644 --- a/src/logger/error.ts +++ b/src/logger/error.ts @@ -4,6 +4,9 @@ import { assembleBuildConfig } from '../common/config'; import StringBuilder from '../common/string-builder'; function errorLoggerWithoutPromise(error: AxiosError, config: ErrorLogConfig = {}) { + if (!error.config) { + return error + } const {config: { method, baseURL, params, url }, response} = error;