From 3dda41f5eb3d5009b216150bf274134930679cdb Mon Sep 17 00:00:00 2001 From: Sean Sundberg Date: Mon, 6 Nov 2023 14:53:28 -0600 Subject: [PATCH] Handle empty news result from Scrape It api (#138) Signed-off-by: Sean Sundberg --- src/services/negative-news/negative-news.impl.ts | 10 ++++++---- src/services/web-scrape/web-scrape.scrapeit.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/services/negative-news/negative-news.impl.ts b/src/services/negative-news/negative-news.impl.ts index 2fb8b0f..dcefd9f 100644 --- a/src/services/negative-news/negative-news.impl.ts +++ b/src/services/negative-news/negative-news.impl.ts @@ -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 + return queue + .add(() => this.service.scrape(params)) + .catch(err => { + console.log('Error accessing Scrapeit: ', {err}) + throw err + }) as Promise } async validateUrls(data: SearchResult[]): Promise<{validUrls: ValidatedSearchResult[], badUrls: ValidatedSearchResult[]}> { diff --git a/src/services/web-scrape/web-scrape.scrapeit.ts b/src/services/web-scrape/web-scrape.scrapeit.ts index 05433f7..4e3c2f0 100644 --- a/src/services/web-scrape/web-scrape.scrapeit.ts +++ b/src/services/web-scrape/web-scrape.scrapeit.ts @@ -11,6 +11,6 @@ export class WebScrapeScrapeit implements WebScrapeApi { scrape(params: WebScrapeParams): Promise { return this.service.scrape(params) - .then(response => response.newsResults); + .then(response => response.newsResults || []); } } \ No newline at end of file