I have a express API endpoint where I need to receive two numbers from the query parameters.
The problem is that I cannot convert them properly into number type constants.
I always get the following typescript error:
Argument of type 'string | ParsedQs | string[] | ParsedQs[]' is not assignable to parameter of type 'string'.
export const getRoutes = async (req: Request, res: Response) => {
const page:number = parseInt(req.query.page)
const limit:number = parseInt(req.query.limit)
parseInt(req.query.page as string)
. Even if it is not - you'll get aNaN
(same as with non parsable string)