fix: ensure error messages are properly typed in API handlers
This commit is contained in:
1 parent
ac8267b431
commit
0821e164ef
5 files changed
+3
-4
No files matched your search
@@ -52,7 +52,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
|
||||
const params = validateParams(req);
|
||||
if ("error" in params) {
|
||||
return respondWithError(res, 400, params.error);
|
||||
return respondWithError(res, 400, params.error as string);
|
||||
}
|
||||
|
||||
const search = new URLSearchParams({ key: params.key, size: params.size });
|
||||
|
||||
@@ -70,7 +70,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
|
||||
const validation = validatePayload(payload);
|
||||
if ("error" in validation) {
|
||||
return respondWithError(res, 400, validation.error);
|
||||
return respondWithError(res, 400, validation.error ?? "Validation failed");
|
||||
}
|
||||
|
||||
const params = validation;
|
||||
|
||||
@@ -47,7 +47,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
|
||||
const params = validateParams(req);
|
||||
if ("error" in params) {
|
||||
return respondWithError(res, 400, params.error);
|
||||
return respondWithError(res, 400, params.error as string);
|
||||
}
|
||||
|
||||
const search = new URLSearchParams({ key: params.key });
|
||||
|
||||
Reference in new issue
Block a user