• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

251
Views
server does not response data in Node JS

I write a router it is pretty straightforward it goes to service and the service connects to the database and the last router responds to a message and data but it doesn't show anything.

The router is like

router.get(
  "/:id",
  wrap(async (req: Request, res: Response, next: NextFunction) => {
    const id = parseInt(req.params.id);
    const result: any = await StudentService.get(id);
    res.status(200).send({
      message: 'Data serve successfully',
      data   : result
  })
  })
);

and the service class is

export class StudentService {
  constructor() {}

  async get(id: number) {
    const queryText = `select * from temp.student_info where id=$1`;
    const connection = await pgConnect.getConnection("slave");
    const result = await (
      await connection.query(queryText, [id])
    ).rows[0];

    return result;
  }
}

in response, it's just waiting but didn't give any data. if I write a console before res.status like below

router.get(
  "/:id",
  wrap(async (req: Request, res: Response, next: NextFunction) => {
    const id = parseInt(req.params.id);
    const result: any = await StudentService.get(id);
    console.log(result)
    res.status(200).send({
      message: 'Data serve successfully',
      data   : result
  })
  })
);

Then I can see the console but I did not get any response. how can solve this?

about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error