return new Promise((resolve, reject) => {
connection.query('SELECT * from `user` WHERE `id` = ?', [id], function (error, rows, fields) {
if (error) {
reject(new Error(error));
}
console.log(rows);
if ( rows === undefined || !rows.length) {
reject(false);
}
resolve(rows[0]);
});
});
undefined
.../models/user.js:105
resolve(rows[0]);
^
TypeError: Cannot read property '0' of undefined