I have a function to which I send some parameters, and depending on those parameters makes a query in a BD or not.
The issue is that I need that if the query is made in the database the application waits for the query to finish to continue with the execution. For that I use promises.
The problem is that if a query is not made to the DB, the function code is not asynchronous, and it does not return a promise, so it gives me an error in the line where I call the function of the type:
TypeError: Cannot read property 'then' of undefined
In the event that a query to the BD is not made as I can do to return some kind of "false promise" and do not throw me this error?