fix: correct empty-result and maxItems handling in routes

This commit is contained in:
2026-04-27 09:34:08 -04:00
parent 974190de6b
commit a802035ca4
4 changed files with 164 additions and 23 deletions

View File

@@ -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 },