Skip to content

Commit

Permalink
Handle empty news result from Scrape It api (#138)
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Sundberg <[email protected]>
  • Loading branch information
seansund authored Nov 6, 2023
1 parent 9c3cd78 commit 3dda41f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/services/negative-news/negative-news.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,12 @@ export class NegativeNewsImpl implements NegativeNewsApi {
"tbm": "nws",
}

return queue.add(() => this.service.scrape(params)).catch(err => {
console.log('Error accessing Scrapeit: ', {err})
throw err
}) as Promise<SearchResult[]>
return queue
.add(() => this.service.scrape(params))
.catch(err => {
console.log('Error accessing Scrapeit: ', {err})
throw err
}) as Promise<SearchResult[]>
}

async validateUrls(data: SearchResult[]): Promise<{validUrls: ValidatedSearchResult[], badUrls: ValidatedSearchResult[]}> {
Expand Down
2 changes: 1 addition & 1 deletion src/services/web-scrape/web-scrape.scrapeit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export class WebScrapeScrapeit implements WebScrapeApi {

scrape(params: WebScrapeParams): Promise<SearchResult[]> {
return this.service.scrape(params)
.then(response => response.newsResults);
.then(response => response.newsResults || []);
}
}

0 comments on commit 3dda41f

Please sign in to comment.