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

112
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report

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 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!