Answer the question
In order to leave comments, you need to log in
Why doesn't reject work?
Database request
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
Answer the question
In order to leave comments, you need to log in
resolve / reject must be returned, otherwise everything falls down to rizolva
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question