Update fetch.ts

This commit is contained in:
Nicolas 2024-10-03 18:55:39 -03:00
parent 25dd16bf2a
commit 668ff3c71b

View File

@ -51,7 +51,7 @@ export async function scrapWithFetch(
const { content, pageStatusCode, pageError } = await fetchAndProcessPdf(url, pageOptions?.parsePDF);
logParams.response_code = pageStatusCode;
logParams.error_message = pageError;
return { content, pageStatusCode, pageError };
return { content, pageStatusCode: response.status, pageError };
} else {
const text = response.data;
logParams.success = true;
@ -67,7 +67,7 @@ export async function scrapWithFetch(
logParams.error_message = error.message || error;
Logger.debug(`⛏️ Axios: Failed to fetch url: ${url} | Error: ${error}`);
}
return { content: "", pageStatusCode: null, pageError: logParams.error_message };
return { content: "", pageStatusCode: error.response?.status ?? null, pageError: logParams.error_message };
} finally {
const endTime = Date.now();
logParams.time_taken_seconds = (endTime - logParams.startTime) / 1000;