Node.js - The Multi Part Could Not Be Bound
Solution 1:
It seems that you have some whitespace messed up in the SQL but that is the least of your problems here.
First of all, always attach a rejection handler to every promise or otherwise your app will crash on errors. Example:
Bad:
f().then(function (articles) { ... });
Good:
f().then(function (articles) { ... }, function (error) { ... });
Also good:
f().then(function (articles) { ... }).catch(function (error) { ... });
See this answer to know why it's important:
Second of all, never concatenate strings with SQL or otherwise you will get SQL injection vulnerabilities. Example:
Bad, unsafe, error prone and hard to maintain:
connection.query(
"SELECT * FROM player WHERE nick = '" + data.login + "' AND pass = '" + data.pass + "'",
function (err, rows) {
//...
}
);
Good, safe, robust and easy to maintain:
connection.query(
"SELECT * FROM player WHERE nick = ? AND pass = ?",
[data.login, data.pass],
function (err, rows) {
// ...
}
);
See those answers for more details:
How to escape mysql special characters with sockets.io/node.js/javascript
Node js - Promise Rejection Warning when process a lot of data
Is it possible to listen for object instantiation in Node.js?
Obligatory comic strip that demonstrates the problem:
Post a Comment for "Node.js - The Multi Part Could Not Be Bound"