Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
outside of client's scope? #60
Hi there. I'm not sure if I have run up against a limitation of this module, or of my skill. I can't seem to do anything with the return of a query outside of the optional function. The only way I can do anything to the data, is to put everything inside that function, i.e. passing the data as locals (res.render). Can you please set me straight?
For instance, I unable to attach the reply to a variable.
Similarly, I am unable to do this:
Only this works, but it is not the ideal construction:
Your second example should work though, but you are probably getting confused about the order in which things run. Check out this program:
This will output:
Note that the "Outside callback" ran first. Since client.get() is a potentially blocking operation, the callback is noted, and control passes immediately (as far as you are concerned) to the next line in your program.
Note also that client.set() and client.get() are both operations that complete asynchronously, but they are guaranteed to complete in order. So you know that the get will not invoke the callback until the set is complete.