In this endpoint handler, is there a way to restrict req.query in NextJS NextApiRequest to just string types rather than string | string[]. For example, someQueryParam here is of string | string[] type but I want to use it as just string type
export default async function handler(
req: NextApiRequest,
res: NextApiResponse<Response>
) {
const { someQueryParam } = req.query;
// pass in someQueryParam as a string into a function call
const result = functionCall(someQueryParam)
}
typescript error when passing someQueryParam into a function that only accepts string type for the argument:
Argument of type 'string | string[]' is not assignable to parameter of type 'string'.
Type 'string[]' is not assignable to type 'string'.
For reference, here is the definition of NextApiRequest in the Nextjs library
also open to any suggestions to somehow use someQueryParam as string type rather than string | string[] type within the handler before passing it into function
