Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

247
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda