Skip to content

Scheduling infrastructure for absolutely everyone.

Adds meaningful response for API caller

Syed Ali Shahbazaffba8bf6601
diff --git a/pages/api/schedules/index.ts b/pages/api/schedules/index.ts
index e1b8d793504..3b8abc776fe 100644
--- a/pages/api/schedules/index.ts
+++ b/pages/api/schedules/index.ts
@@ -15,7 +15,12 @@ async function createOrlistAllSchedules(
{ method, body, userId, isAdmin, prisma }: NextApiRequest,
res: NextApiResponse<SchedulesResponse | ScheduleResponse>
) {
- const safe = schemaScheduleBodyParams.safeParse(safeParseJSON(body));
+ body = safeParseJSON(body);
+ if (!body.success) {
+ res.status(400).json({ message: body.message });
+ }
+
+ const safe = schemaScheduleBodyParams.safeParse(body);
if (!safe.success) {
res.status(400).json({ message: "Bad request" });