Why do we have a callback function?



Why do we have a callback function?


Because of how Node-sqlite3 works when running the SQL query, it receives first a promise, which is like when we call customer service and you get on the waiting line with background music, that would be a promise that a representative will be with you “shortly”.
Once that promise returns the corresponding data of our query, sqlite3 decided that the best way is to require a callback function in their methods.
The moment data has returned, the function will be called passing the row or rows into it.

The callback is the way we can interact and use the returned results from the database however we need to.