# HG changeset patch # User Yaroslav Zhuravlev # Date 1585044747 0 # Node ID ba9bfd064a612044bd2d9c78cf15a649bef9991a # Parent 4ca80854401342a942349951b35cdc0059976331 Renamed and corrected example in njs. diff -r 4ca808544013 -r ba9bfd064a61 xml/en/docs/njs/examples.xml --- a/xml/en/docs/njs/examples.xml Thu Mar 19 13:16:48 2020 +0300 +++ b/xml/en/docs/njs/examples.xml Tue Mar 24 10:12:27 2020 +0000 @@ -9,7 +9,7 @@
+ rev="9">
@@ -354,14 +354,14 @@
-
+
The example works since 0.3.8. nginx.conf: -js_include promisified_subrequest.js; +js_include subrequests_chaining.js; location /start { js_content content; @@ -378,16 +378,16 @@ -promisified_subrequest.js: +subrequests_chaining.js: function content(r) { - r.subrequest(r, '/auth') + r.subrequest('/auth') .then(reply => JSON.parse(reply.responseBody)) .then(response => { if (!response['token']) { throw new Error("token is not available"); } - return token; + return reply['token']; }) .then(token => { r.subrequest('/backend', `token=${token}`) diff -r 4ca808544013 -r ba9bfd064a61 xml/ru/docs/njs/examples.xml --- a/xml/ru/docs/njs/examples.xml Thu Mar 19 13:16:48 2020 +0300 +++ b/xml/ru/docs/njs/examples.xml Tue Mar 24 10:12:27 2020 +0000 @@ -9,7 +9,7 @@
+ rev="9">
@@ -354,14 +354,14 @@
-
+
Пример работает начиная с версии 0.3.8. nginx.conf: -js_include promisified_subrequest.js; +js_include subrequests_chaining.js; location /start { js_content content; @@ -378,16 +378,16 @@ -promisified_subrequest.js: +subrequests_chaining.js: function content(r) { - r.subrequest(r, '/auth') + r.subrequest('/auth') .then(reply => JSON.parse(reply.responseBody)) .then(response => { if (!response['token']) { throw new Error("token is not available"); } - return token; + return reply['token']; }) .then(token => { r.subrequest('/backend', `token=${token}`)