De connection.query
functie heeft twee tot drie argumenten:de SQL-instructie (de waarden) en de callback. Hier neemt de functie vier argumenten aan, dus hij denkt [first_name, last_name,]
is het terugbellen.
Wat u kunt doen is:
...
connection.query('INSERT INTO user SET user_id = ?, first_name = ?,last_name = ?', [decoded.id, first_name, last_name,], (err, rows) => {
if (!err) {
res.render('add-crew', { alert: 'Crew member added succesfully!' });
} else {
console.log(err);
}
console.log('The data from user table:\n', rows);
});
...
Ik hoop dat dit is wat je zoekt.
Bewerken je zou ook kunnen doen:
...
connection.query('INSERT INTO user SET ?', {user_id: decoded.id, first_name: first_name, last_name: last_name}, (err, rows) => {
if (!err) {
res.render('add-crew', { alert: 'Crew member added succesfully!' });
} else {
console.log(err);
}
console.log('The data from user table:\n', rows);
});
...