mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-06 05:58:35 +08:00
[SDK] fixed none and undefined on response
This commit is contained in:
parent
ad49503f8a
commit
bafcc008bc
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mendable/firecrawl-js",
|
||||
"version": "1.11.0",
|
||||
"version": "1.11.1",
|
||||
"description": "JavaScript SDK for Firecrawl API",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
@ -571,17 +571,30 @@ export default class FirecrawlApp {
|
||||
allData = data;
|
||||
}
|
||||
}
|
||||
return ({
|
||||
|
||||
let resp: CrawlStatusResponse | ErrorResponse = {
|
||||
success: response.data.success,
|
||||
status: response.data.status,
|
||||
total: response.data.total,
|
||||
completed: response.data.completed,
|
||||
creditsUsed: response.data.creditsUsed,
|
||||
expiresAt: new Date(response.data.expiresAt),
|
||||
next: response.data.next,
|
||||
data: allData,
|
||||
error: response.data.error,
|
||||
})
|
||||
data: allData
|
||||
}
|
||||
|
||||
if (!response.data.success && response.data.error) {
|
||||
resp = {
|
||||
...resp,
|
||||
success: false,
|
||||
error: response.data.error
|
||||
} as ErrorResponse;
|
||||
}
|
||||
|
||||
if (response.data.next) {
|
||||
(resp as CrawlStatusResponse).next = response.data.next;
|
||||
}
|
||||
|
||||
return resp;
|
||||
} else {
|
||||
this.handleError(response, "check crawl status");
|
||||
}
|
||||
@ -805,17 +818,30 @@ export default class FirecrawlApp {
|
||||
allData = data;
|
||||
}
|
||||
}
|
||||
return ({
|
||||
|
||||
let resp: BatchScrapeStatusResponse | ErrorResponse = {
|
||||
success: response.data.success,
|
||||
status: response.data.status,
|
||||
total: response.data.total,
|
||||
completed: response.data.completed,
|
||||
creditsUsed: response.data.creditsUsed,
|
||||
expiresAt: new Date(response.data.expiresAt),
|
||||
next: response.data.next,
|
||||
data: allData,
|
||||
error: response.data.error,
|
||||
})
|
||||
data: allData
|
||||
}
|
||||
|
||||
if (!response.data.success && response.data.error) {
|
||||
resp = {
|
||||
...resp,
|
||||
success: false,
|
||||
error: response.data.error
|
||||
} as ErrorResponse;
|
||||
}
|
||||
|
||||
if (response.data.next) {
|
||||
(resp as BatchScrapeStatusResponse).next = response.data.next;
|
||||
}
|
||||
|
||||
return resp;
|
||||
} else {
|
||||
this.handleError(response, "check batch scrape status");
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import os
|
||||
|
||||
from .firecrawl import FirecrawlApp # noqa
|
||||
|
||||
__version__ = "1.8.0"
|
||||
__version__ = "1.8.1"
|
||||
|
||||
# Define the logger for the Firecrawl project
|
||||
logger: logging.Logger = logging.getLogger("firecrawl")
|
||||
|
@ -267,16 +267,24 @@ class FirecrawlApp:
|
||||
break
|
||||
status_data['data'] = data
|
||||
|
||||
return {
|
||||
'success': True,
|
||||
response = {
|
||||
'status': status_data.get('status'),
|
||||
'total': status_data.get('total'),
|
||||
'completed': status_data.get('completed'),
|
||||
'creditsUsed': status_data.get('creditsUsed'),
|
||||
'expiresAt': status_data.get('expiresAt'),
|
||||
'data': status_data.get('data'),
|
||||
'error': status_data.get('error'),
|
||||
'next': status_data.get('next', None)
|
||||
'data': status_data.get('data')
|
||||
}
|
||||
|
||||
if 'error' in status_data:
|
||||
response['error'] = status_data['error']
|
||||
|
||||
if 'next' in status_data:
|
||||
response['next'] = status_data['next']
|
||||
|
||||
return {
|
||||
'success': False if 'error' in status_data else True,
|
||||
**response
|
||||
}
|
||||
else:
|
||||
self._handle_error(response, 'check crawl status')
|
||||
@ -476,16 +484,24 @@ class FirecrawlApp:
|
||||
break
|
||||
status_data['data'] = data
|
||||
|
||||
return {
|
||||
'success': True,
|
||||
response = {
|
||||
'status': status_data.get('status'),
|
||||
'total': status_data.get('total'),
|
||||
'completed': status_data.get('completed'),
|
||||
'creditsUsed': status_data.get('creditsUsed'),
|
||||
'expiresAt': status_data.get('expiresAt'),
|
||||
'data': status_data.get('data'),
|
||||
'error': status_data.get('error'),
|
||||
'next': status_data.get('next', None)
|
||||
'data': status_data.get('data')
|
||||
}
|
||||
|
||||
if 'error' in status_data:
|
||||
response['error'] = status_data['error']
|
||||
|
||||
if 'next' in status_data:
|
||||
response['next'] = status_data['next']
|
||||
|
||||
return {
|
||||
'success': False if 'error' in status_data else True,
|
||||
**response
|
||||
}
|
||||
else:
|
||||
self._handle_error(response, 'check batch scrape status')
|
||||
|
Loading…
x
Reference in New Issue
Block a user