mirror of
https://github.com/mendableai/firecrawl.git
synced 2024-11-16 11:42:24 +08:00
Nick: fixed map exception
This commit is contained in:
parent
ef71940429
commit
b8b8522b33
|
@ -1,10 +1,14 @@
|
|||
import axios from "axios";
|
||||
import dotenv from "dotenv";
|
||||
import { SearchResult } from "../../src/lib/entities";
|
||||
import * as Sentry from "@sentry/node";
|
||||
import { Logger } from "../lib/logger";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
export async function fireEngineMap(q: string, options: {
|
||||
export async function fireEngineMap(
|
||||
q: string,
|
||||
options: {
|
||||
tbs?: string;
|
||||
filter?: string;
|
||||
lang?: string;
|
||||
|
@ -12,7 +16,9 @@ export async function fireEngineMap(q: string, options: {
|
|||
location?: string;
|
||||
numResults: number;
|
||||
page?: number;
|
||||
}): Promise<SearchResult[]> {
|
||||
}
|
||||
): Promise<SearchResult[]> {
|
||||
try {
|
||||
let data = JSON.stringify({
|
||||
query: q,
|
||||
lang: options.lang,
|
||||
|
@ -24,7 +30,9 @@ export async function fireEngineMap(q: string, options: {
|
|||
});
|
||||
|
||||
if (!process.env.FIRE_ENGINE_BETA_URL) {
|
||||
console.warn("(v1/map Beta) Results might differ from cloud offering currently.");
|
||||
console.warn(
|
||||
"(v1/map Beta) Results might differ from cloud offering currently."
|
||||
);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -38,8 +46,13 @@ export async function fireEngineMap(q: string, options: {
|
|||
};
|
||||
const response = await axios(config);
|
||||
if (response && response) {
|
||||
return response.data
|
||||
return response.data;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
} catch (error) {
|
||||
Logger.error(error);
|
||||
Sentry.captureException(error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user