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

196
Views
Node JS API responds nothing on increasing request params and keeps sending the request to the server

I am using following api which responds nothing http://localhost:6150/api/v1/simpleSurveyData/abc/:projectId/:startDate/:endDate/:visitMonth

but, when i remove any of the four params or give less than four params. And adjust api route in node js accordingly server starts to response.

What i found is increasing params to four, my Node JS code does not come into the api route but although server does not give error but request just sending.

router.get("api/v1/simpleSurveyData/abc/:projectId/:startDate/:endDate/:visitMonth",
  async (req, res, next) => {
    console.log("first")

    try {
      console.log("first")
 
      res.status(200).send("response");
    } catch (error) {
      next(error);
      console.log(error);
    }
  }
);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The problem is because you extract the data from url path NOT a query parameter. Please use query parameter. Example code below.

"api/v1/simpleSurveyData/abc/:projectId/:startDate/:endDate/:visitMonth" should be "api/v1/simpleSurveyData/abc?projectId=<projectId>&startDate=<startDate>&endDate=<endDate>&visitMonth=<visitMonth>"

Example express controller

export async function upvoteQuestion(req: Request, res: Response, next: NextFunction): Promise<void> {
    try {
        const questionId: string = req.params.question_id
        await db<Question>('question').where('id', questionId).increment('upvote', 1)
        res.status(200).json(<GeneralResponse>{
            status: responseStatus.success,
            message: 'Successfully vote up question'
        })
    } catch (error: unknown) {
        next(error)
    }
}

I extract the information of question id in url parameter by using req.params.question_id.

You can Google for more information.

about 4 years ago · Juan Pablo Isaza 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!