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

110
Vistas
PUT does not update Mysql thru REST api / JWT

I am trying to make an update request using Jwt (Tokens) and Node.Js with a backend in mysql. It just tells me in Postman that the record has been updated, i try to see where the update took place and i could not find a thing. Nothing updated.

My code is looking thus :

app.put('/api/v1/logistics/update_profile', async function (req, res, next) {
  try {
    if (
      !req.headers.authorization ||
      !req.headers.authorization.startsWith('Bearer ') ||
      !req.headers.authorization.split(' ')[1]
    ) {
      return res.status(422).json({ message: 'Please Provide Token!' });
    }

    const theToken = req.headers.authorization.split(' ')[1];
    const decoded = jwt.verify(theToken, 'fasta-logistics');

    var fullname = req.body.fullname;
    var email = req.body.email;
    var state = req.body.state;
    var city = req.body.city;
    var phone_num = req.body.phone_num;
    var company_type = req.body.company_type;
    var company_name = req.body.company_name;
    var company_regnum = req.body.company_regnum;
    var l_licensenumber = req.body.l_licensenumber;
    var company_address = req.body.company_address;

    dbConn.query(
      'UPDATE XXXXXx SET fullname =? , email =?, state=?, city=?, phone_num=?, company_type=?, company_name =?, company_regnum =?, l_licensenumber =?, company_address =?  where id =?',
      [
        fullname,
        email,
        state,
        city,
        phone_num,
        company_type,
        company_name,
        company_regnum,
        l_licensenumber,
        company_address,
        decoded.id,
      ],
      function (error, results, fields) {
        if (error) throw error;

        return res.send({
          error: false,
          data: results,
          message: 'User Updated Successfully',
        });
      }
    );
  } catch (err) {
    next(err);
  }
});

Why does it tell me the records has been updated and nothing happens? Please I need guidance here of some sort.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

return res.json({ error: false, data: results, message: 'User Updated Successfully' }); should work.

about 4 years ago · Juan Pablo Isaza Denunciar

0

To be honest, I don't know how the "dbConn.query" works, but I guess you misspelled the arguments order or something like that. I can suggest you to use ORMs instead (at least query builders like knex), because they have declarative and more readable code, huge doc and community and issues like this doesn't exist in there.

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