Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

245
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda