Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(js-sdk): improve error logging

Gergő Móricz0d1b46d47630
diff --git a/apps/js-sdk/firecrawl/src/index.ts b/apps/js-sdk/firecrawl/src/index.ts
index 949cfe98a..661ce34b7 100644
--- a/apps/js-sdk/firecrawl/src/index.ts
+++ b/apps/js-sdk/firecrawl/src/index.ts
@@ -1,4 +1,4 @@
-import axios, { type AxiosResponse, type AxiosRequestHeaders } from "axios";
+import axios, { type AxiosResponse, type AxiosRequestHeaders, AxiosError } from "axios";
import type * as zt from "zod";
import { zodToJsonSchema } from "zod-to-json-schema";
import { WebSocket } from "isows";
@@ -452,11 +452,19 @@ export default class FirecrawlApp {
* @param headers - The headers for the request.
* @returns The response from the GET request.
*/
- getRequest(
+ async getRequest(
url: string,
headers: AxiosRequestHeaders
): Promise<AxiosResponse> {
- return axios.get(url, { headers });
+ try {
+ return await axios.get(url, { headers });
+ } catch (error) {
+ if (error instanceof AxiosError && error.response) {
+ return error.response as AxiosResponse;
+ } else {
+ throw error;
+ }
+ }
}
/**