Answer the question
In order to leave comments, you need to log in
How to send object to mysql database via nodejs?
How can I send an object to the database?
When I execute this:
connection.query('INSERT INTO `users` SET winhist = ? WHERE uid = ?', [win, uid], function (error, results, fields) {
if (error) throw error;
console.log(results)
});
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlState: '42000',
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 'WHERE uid = 458035084 ' at line 1",
sql: 'INSERT INTO `users` SET winhist = \'{\\"name\\":\\"RANDOM\\",\\"price\\":105,\\"discount \\":5,\\"img\\":\\" https://i.imgur.com/F0hjmJ8.png\\",\\"maxLPrizes\\":4}\ ' WHERE uid = 458035084 '
}
let win = JSON.parse(req.body.win)
let win = req.body.win
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question