From bcc1147f81e9bf501469618a0b30bdae8464977c Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Mon, 18 Sep 2023 18:23:37 +0530 Subject: [PATCH] fix: clear regression and extension recovers response for error status codes --- .../src/platform/std/interceptors/browser.ts | 5 +++-- .../src/platform/std/interceptors/extension.ts | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/hoppscotch-common/src/platform/std/interceptors/browser.ts b/packages/hoppscotch-common/src/platform/std/interceptors/browser.ts index 006de1f8e..b4381e99a 100644 --- a/packages/hoppscotch-common/src/platform/std/interceptors/browser.ts +++ b/packages/hoppscotch-common/src/platform/std/interceptors/browser.ts @@ -2,6 +2,7 @@ import * as E from "fp-ts/Either" import { Interceptor, InterceptorError, + NetworkResponse, RequestRunResult, } from "../../../services/interceptor.service" import axios, { AxiosRequestConfig, CancelToken } from "axios" @@ -51,7 +52,7 @@ async function runRequest( const timeEnd = Date.now() - return E.right({ + return E.right({ ...res, config: { timeData: { @@ -64,7 +65,7 @@ async function runRequest( const timeEnd = Date.now() if (axios.isAxiosError(e) && e.response) { - return E.right({ + return E.right({ ...e.response, config: { timeData: { diff --git a/packages/hoppscotch-common/src/platform/std/interceptors/extension.ts b/packages/hoppscotch-common/src/platform/std/interceptors/extension.ts index 96beac01f..99caa6095 100644 --- a/packages/hoppscotch-common/src/platform/std/interceptors/extension.ts +++ b/packages/hoppscotch-common/src/platform/std/interceptors/extension.ts @@ -228,6 +228,11 @@ export class ExtensionInterceptorService return E.right(result) } catch (e) { + // TODO: improve type checking + if ((e as any).response) { + return E.right((e as any).response) + } + return E.left({ // TODO: i18n this humanMessage: {