Friday, 12 July 2019

Beginner callback question

I have the following ``` db.serialize (function () { exports.run = function(query, message) { db.run(query, function(err) { if (err) { console.error(err.message, ); return 0; } else{ console.log(message,": ", this.changes, "\n"); return 1; } }); } }) ```My problem is that it always return undefined. Someone told me the followingdb.run is an asynchronous call. exports.run has no return statement so it always returns undefined.But I don’t understand what they meant by exports.run has no return statetement when return is written explicitly.He also redirected me to that link on stack overflow , but it’s referring to another problem (I guess?) Do you have any idea? (Sorry for the newbie question)

Submitted July 12, 2019 at 11:02AM by StrenghGeek

No comments:

Post a Comment