Adds meaningful response for API caller
parent
3bdebba21e
commit
affba8bf66
|
@ -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" });
|
||||||
|
|
Loading…
Reference in New Issue