Adds meaningful response for API caller

pull/9078/head
Syed Ali Shahbaz 2022-10-07 13:13:56 +05:30 committed by GitHub
parent 3bdebba21e
commit affba8bf66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -15,7 +15,12 @@ async function createOrlistAllSchedules(
{ method, body, userId, isAdmin, prisma }: NextApiRequest, { method, body, userId, isAdmin, prisma }: NextApiRequest,
res: NextApiResponse<SchedulesResponse | ScheduleResponse> 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) { if (!safe.success) {
res.status(400).json({ message: "Bad request" }); res.status(400).json({ message: "Bad request" });