Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: clear regression and extension recovers response for error status codes

Andrew Bastinbcc1147f81e9
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(<NetworkResponse>{
...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(<NetworkResponse>{
...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(<InterceptorError>{
// TODO: i18n this
humanMessage: {