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

244
Views
Node.js postman infinite request time(*no errors and database is updated fine) on PUT request

I've been stuck on this for way too long without being able to find where is my error, I am making an API with node.js through express and all Restful functions work fine for me except the updating which gets stuck on postman "sending request" while the database is updated without problems, I suspect the error is somewhere in the response but I swear I've tried each combination that came to mind to get the response to no avail. Here's my code for this:

In the router

router.put('/:id', hlpJWT.authenticateToken,  ctrProfile.updateInfo);

In the controller

updateInfo = async function (req, res, next) {
  const input = {
     name: req.body.name,
     password: await srvAuth.cryptPass(req.body.password),
     ..., // other input fields
  };
  let user = await srvProfile.updateProfile(input);
  if (user) res.json(user);
  else {
    res.status(404);
    res.json({ error: "user not found" });
  }
};

in the service

updateProfile = function (input) {
  return new Promise((resolve, reject) => {
    query(
      "UPDATE users SET ? WHERE ?",
      [
        {
          name: input.name,
          ... // more input fields
        },
        { user_id: input.id },
      ],
      function (error, result) {
        if (error) {
          return reject(error);
        }
        return resolve(result);
      }
    );
  });
};

Thanks in advance to anyone willing to help

UPDATE: Ultimately I just updated to express v5 and it works fine there, so it definitely was error handling that was causing it, but I never figured out what specifically.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It sounds like you have an unhandled error on this request which prevents a response from getting sent to your client, in this case, Postman. It could be either the password creation or user update that's triggering this.

If you wrap your request like this, I'm sure your client will get a response:

try {
  const password = await srvAuth.cryptPass(req.body.password);
  const input = {
    ..., // input fields
    password,
  }
  let user = await srvProfile.updateProfile(input);

  if (user) {
    res.json(user);
  } else {
    res.status(404);
    res.json({error: 'user not found'});
  } 
} catch (e) {
  res.status(500).json({error: e, message: 'internal server error'});
}
         
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!