title: nodejs - How to have request inside then?
body: <p>I need to generate a <code>key</code> first then use the <code>key</code> to run <code>request</code> Below code is just an example</p>
  
  <pre><code> const getKey = () =&gt; {
          return new Promises(resolve, reject) =&gt; {
              const value =  somecode here;
               resolve (value);
          }
      }
  
  getKey().then(val =&gt; {
      request({method: 'GET', url: 'http://www.google.com', key: val}, function (error, response, body) {
              if (!error){
                  console.log(body)
              }
  
          }); 
      }
  });
  </code></pre>
  
  <p>How can I chain them together using <code>Promises</code></p>