Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

389
Views
Node.js Request params undefined

I have a get route that receives two parameters "limit" and "page".

router.get('/:limit/:page', userController.list);

class UserController{
    public list(req:Request, res:Response): void{
        const limit:number = +req.params.limit || 25;
        const page:number = +req.params.page || 0; }
}
export const userController: UserController = new UserController();

The problem is these params are undefined when I make the request from postman.

localhost:3000/api/users/?limit=2&page=1
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You're passing query parameters but your route wants route parameters.

To use route parameters, your request should look like http://localhost:3000/api/users/2/1

Typically though, pagination is passed as query parameters in which case your route handler should look like this

import { Request, Response } from "express";

interface PaginationQuery {
  limit?: number;
  page?: number;
}

type PaginationRequest = Request<{}, any, any, PaginationQuery>;

router.get('/', userController.list);

class UserController{
  public list(req: PaginationRequest, res: Response): void {
    const limit = req.query.limit ?? 25;
    const page = req.query.page ?? 0;
  }
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!