1
The mistake Cannot read property 'query' of undefined
is reported when trying to save data to the database. However, the Property query works for getNews. Ex:
function NewsDAO(database){
this._database = database;
}
NewsDAO.prototype.getNews = function(callback){
this._database.query('SELECT * FROM news', callback);
}
NewsDAO.prototype.saveNotice = (notice, callback) =>{
this._database.query('INSERT INTO noticias SET ?', notice, callback);
console.log(this._database);
}
module.exports = () => {
return NewsDAO;
}
When I give a console.log
in the _database
in the method getNews()
, I can see all properties. When I do the same on saveNotice()
, returns a undefined
.
What could be?
It worked super well! Thanks for the clarifications.
– Miqueias Maia