title: How to pass variable value from js file to nginx config with njs module
body: <p>I am trying to use njs to have chain request with nginx njs, i have below issue
  here is my javascript file and my scenario is
  I have two of API.
  I want to request first api and get it's reponse then append first api's response (cloud be JSON properties )  second api's header</p>
  <pre><code>async function chain(r) {
    r.headersOut[&quot;Content-Type&quot;] = &quot;application/json&quot;;
    var result = await r.subrequest(&quot;/validation&quot;, { method: &quot;POST&quot; });
    var json = JSON.parse(result.responseText);
  
    headers = json.fullName;// where to put this header and append it to second request header ?
    var result1 = await r.subrequest(&quot;/persistance&quot;);
  
    r.return(result1.status, result1.responseBody);
  
  }
  
  function getHeaders() {
    return headers;
  }
  
  export default { chain, getHeaders };
  </code></pre>
  <p>And my nginx config file</p>
  <pre><code>js_import http.js;
  js_set $headers http.getHeaders; // here am trying to get headers from variable in http.js but is it alwat null and undefended
  server {
      listen       80;
      listen  [::]:80;
      server_name  localhost;
         
      error_page   500 502 503 504  /50x.html;
      location = /50x.html {
          root   /usr/share/nginx/html;
      }
         
      location ~ ^/.*$ {
        js_content http.chain;
      }
  
      location = /persistance {
         proxy_set_header accountId $headers; //it is always undefined, I think it is because declared on the top of file and it is nginx directives
         proxy_pass http://192.168.2.76:5001/academicyear/list;      
      }
       
      location = /validation {
         proxy_pass http://192.168.2.76:8088/v1/user/validation;
      }
  
  }
  </code></pre>
  <p>I use <strong>subrequest</strong> and <strong>then</strong> it was the same issue</p>