fix: correct empty-result and maxItems handling in routes
This commit is contained in:
@@ -29,7 +29,12 @@ export async function facebookRoute(req: Request): Promise<Response> {
|
||||
hideUnstableResults: true,
|
||||
})
|
||||
: await fetchFacebookItems(SEARCH_QUERY, 1, LOCATION, maxItems);
|
||||
if (!items || items.length === 0)
|
||||
|
||||
const isEmpty = hideUnstableResults
|
||||
? items.results.length === 0 && items.unstableResults.length === 0
|
||||
: !items || items.length === 0;
|
||||
|
||||
if (isEmpty)
|
||||
return Response.json(
|
||||
{ message: "Search didn't return any results!" },
|
||||
{ status: 404 },
|
||||
|
||||
Reference in New Issue
Block a user