Variable scope in javascript module
Valentin V. Bartenev
vbart at nginx.com
Tue Oct 30 22:27:40 UTC 2018
On Wednesday, 31 October 2018 00:55:20 MSK you wrote:
[..]
> However, when i run it, the result is as below :
> The suprising thing is the order it is logged : it seems : as we go for
> async, perhaps both request are started at the same time so each one get a
> starting of 403 (no yet updated). Could this be the pb ? What could be the
> solution ? Run subrequest without giving the done function as callback and
> directly test the return status ?
[..]
Subrequests are async. That allows you to do a lot of interesting stuff,
like in this example where two subrequests are run in parallel:
http://nginx.org/en/docs/njs/examples.html#fast_response
If you want to schedule the second subrequest only after the first one is
finished, then simply put your second subrequest call inside the done
callback of the first one.
wbr, Valentin V. Bartenev
More information about the nginx
mailing list