1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-08-29 20:21:50 +02:00

fix: return response status code (#5815)

This commit is contained in:
Arik Chakma
2024-06-06 20:34:54 +06:00
committed by Kamran Ahmed
parent ed40bf51b0
commit d2e3fee99a

View File

@@ -35,6 +35,7 @@ export async function httpCall<
url: string,
options?: HttpOptionsType,
): Promise<ApiReturn<ResponseType, ErrorType>> {
let statusCode: number = 0;
try {
const fingerprintPromise = await fp.load();
const fingerprint = await fingerprintPromise.get();
@@ -50,6 +51,7 @@ export async function httpCall<
...(options?.headers ?? {}),
}),
});
statusCode = response.status;
// @ts-ignore
const doesAcceptHtml = options?.headers?.['Accept'] === 'text/html';
@@ -83,7 +85,7 @@ export async function httpCall<
return {
response: undefined,
error: {
status: 0,
status: statusCode,
message: error.message,
},
};