Skip to content

Commit

Permalink
NetworkInterceptorXHR undefined status code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
RNEvok committed Jun 20, 2024
1 parent 973daf3 commit cbafc04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Network/NetworkInterceptorXHR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { NetworkInterceptorApi } from './AbstractInterceptor';
import { NetworkInterceptorCallbacksTable } from '../types/types';
import { shouldProceedIntercepted } from './helpers';
import { codebudConsoleLog } from '../helpers/helperFunctions';
import { SPECIAL_HTTP_STATUS_CODES } from '../constants/httpStatusCodes';

type Callback = (data: any) => void;

Expand All @@ -29,8 +30,8 @@ class NetworkInterceptorXHR extends NetworkInterceptorApi {

protected async formatResponse(response: any) {
const formattedResponse = {
status: response.status,
statusText: response.status.toString(),
status: response.status ?? SPECIAL_HTTP_STATUS_CODES.STATUS_CODE_UNDEFINED.STATUS,
statusText: response.status?.toString() ?? SPECIAL_HTTP_STATUS_CODES.STATUS_CODE_UNDEFINED.STATUS_TEXT,
data: response.response,
responseHeaders: response.responseHeaders
};
Expand Down
6 changes: 6 additions & 0 deletions constants/httpStatusCodes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const SPECIAL_HTTP_STATUS_CODES = {
STATUS_CODE_UNDEFINED: {
STATUS: 199,
STATUS_TEXT: "199 Intercepted response original code is undefined"
}
};

0 comments on commit cbafc04

Please # to comment.