Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

filter out linkIds that don't exist

Steven Tey134c49a9119c
diff --git a/apps/web/app/api/customers/count/route.ts b/apps/web/app/api/customers/count/route.ts
index 23714cb236..10544a6270 100644
--- a/apps/web/app/api/customers/count/route.ts
+++ b/apps/web/app/api/customers/count/route.ts
@@ -72,16 +72,19 @@ export const GET = withWorkspace(async ({ workspace, searchParams }) => {
},
});
- return NextResponse.json(
- data.map((d) => {
+ const enrichedData = data
+ .map((d) => {
const link = links.find(({ id }) => id === d.linkId);
+ if (!link) return null;
return {
...d,
shortLink: link?.shortLink,
url: link?.url,
};
- }),
- );
+ })
+ .filter(Boolean);
+
+ return NextResponse.json(enrichedData);
}
const count = await prisma.customer.count({