Update pages/api/availability/_get.ts

improve error message team no members

Co-authored-by: Omar López <zomars@me.com>
pull/9078/head
Agusti Fernandez Pardo 2022-07-08 19:33:37 +02:00 committed by GitHub
parent f6faa8bc46
commit a72fbfa093
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -37,7 +37,7 @@ async function handler(req: NextApiRequest) {
select: { members: true },
});
if (!team) throw new HttpError({ statusCode: 404, message: "teamId not found" });
if (!team.members) throw new HttpError({ statusCode: 404, message: "teamId not found" });
if (!team.members) throw new HttpError({ statusCode: 404, message: "team has no members" });
const allMemberIds = team.members.map((membership) => membership.userId);
const members = await prisma.user.findMany({
where: { id: { in: allMemberIds } },