title: Get data from REST API to jsreports
body: <p>I could successfully get data from the following script and show in report.</p>
  
  <pre><code>function beforeRender(done){
      require("request")({url:"http://nicolas.kruchten.com/pivottable/examples/mps.json",json:true},function(err, response, body){
          request.data = {posts:body};
          done();
      })    
  }
  </code></pre>
  
  <p>I used this, </p>
  
  <pre><code>&lt;h1&gt;Request&lt;/h1&gt;
  
  &lt;table style='border-style:solid'&gt;
    &lt;tr&gt;
      &lt;th&gt;Province&lt;/th&gt;
      &lt;th&gt;Party&lt;/th&gt;
      &lt;th&gt;Name&lt;/th&gt;
    &lt;/tr&gt;
    {{for posts}}
    &lt;tr&gt;
      &lt;td&gt;{{:Province}}&lt;/td&gt;
      &lt;td&gt;{{:Party}}&lt;/td&gt;
      &lt;td&gt;{{:Name}}&lt;/td&gt;
    &lt;/tr&gt;  
    {{/for}}    
  &lt;/table&gt;
  </code></pre>
  
  <p>But when I call a REST api using following query it gets data and writes in console but does not show in report.</p>
  
  <pre><code>var request = require('request');
  
  function beforeRender(done){
      require('request')({headers: {
      'sToken': 'qq',
      'log': 'dd'
    }, url: 'http://localhost:3000/com.dd.com/Inventory' , json:true },
      function(error, response, body) {
          request.data = {posts:body};
           console.log(request.data );
          done();
      });
  }
  </code></pre>
  
  <p>HTML code</p>
  
  <pre><code>&lt;h1&gt;Request&lt;/h1&gt;
  &lt;table style='border-style:solid'&gt;
    &lt;tr&gt;
      &lt;th&gt;Name&lt;/th&gt;
    &lt;/tr&gt;
     {{for posts}}
    &lt;tr&gt;
      &lt;td&gt;{{:Name}}&lt;/td&gt;
    &lt;/tr&gt;  
      {{/for}}    
  &lt;/table&gt;
  </code></pre>
  
  <p>JSON string returned:</p>
  
  <pre><code>{ posts:
     { Id: '700',
       Name: 'myName',
       __osHeaders:
        { Version: '{EFF95F4C-2FA2-11E5-BA94-040150C75001}',
          Namespace: 'com.dd.com',
          Class: 'Inventory',
          Tenant: '123',
          LastUdated: '2015-07-21 08:20:56.197248204 -0400 EDT' } } }
  </code></pre>
  
  <p>Engine used: jsrender
  <br> Recipe: phantom-pdf </p>
  
  <p>How can I display the values in Report? Where have I gone wrong when using the API?</p>