Skip to content

Commit

Permalink
Update fetch.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
nickscamara committed Oct 3, 2024
1 parent 25dd16b commit 668ff3c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/api/src/scraper/WebScraper/scrapers/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 668ff3c

Please sign in to comment.