Hi,
We’re trying to create a custom service using NodeJS in our DreamFactory 2.2.0 server, but we have a problem with asynchronous operations. It seems that the execution of the script finishes without waiting for asynchronous operations to finish.
For example, when using the following code which uses promises:
myApi.authentication
.login("mylogin", "mypassword")
.then(function(result) {
console.log("Auth correct: ", result);
event.response.content = { result: "Authed" };
});
event.response.content = { result: "Exited" };
It seems that the service always returns { result: "Exited" }
but at a later time we can see the "Auth correct"
log trace.
Probably this is a similar problem to Help with my nodejs scripting service
¿How can the service be configured to wait for asynchronous operations?
Thanks in advance.