Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

Update data with NodeJs

$
0
0

I am trying to update my user data in database with node app (using expressJs) but it returns this error in terminal:

 sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL WHERE `id` = '1'' at line 1",
  sqlState: '42000',
  index: 0,
  sql: "UPDATE `users` SET NULL WHERE `id` = '1'"

Code

index.js

var Users = require('./routes/Users');
app.put('/users/:id/update', Users.update);

Users.js

'use strict';

var response = require('../res');

exports.update = function(req, res) {
    req.getConnection(function(err, connection) {
        connection.query('UPDATE `users` SET ? WHERE `id` = ?',  [req.body, req.params.id], function(err, rows) {
            if (err)
                console.log("%s ", err);

            response.success(rows, res);
        });
    });
};

sending request

one

Can you tell me what i did wrong?


Viewing all articles
Browse latest Browse all 138163

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>