This question has already been answered:
Recently I program under the node and now I run into asynchrony.
The problem is this :
I have a module that exports a function to work with the database, and before the function is setting the database.
Setup is asynchronous + requests involving human.
And here comes the problem:
the exported function should work from the already configured database, and since setting is asynchronous, the first function call occurs before the end of the setting.
I do not know how best to describe, but I can’t upload the code.
As a result, I came to the conclusion that I need to somehow make my asynchronous function so that the calls of the exported function are postponed before the database is configured.
How can I do that? And preferably without third-party libraries.