title: How to return value then-catch block
body: <p>My Codes below;</p>
  
  <p>I've a then-catch block. My responseArray is a global variable. i got response from functionName function; but i can't use result out of  then block. How can i use then response out of block?</p>
  
  <p>My Codes below;</p>
  
  <p>I've a then-catch block. My responseArray is a global variable. i got response from functionName function; but i can't use result out of  then block. How can i use then response out of block?</p>
  
  <pre><code>module.exports = {
   foo1: function(param){
     return new Promise((resolve,reject) =&gt; {
        var result = //some code here
        resolve(result);
     });
   },
   foo2: function(param){
     return new Promise((resolve,reject) =&gt; {
        this.foo1('abc').then(function(res){
          let response = {
              'item':'ok',
              'result':res.some_field
          };
          console.log(response);  // its ok here. 
          responseArray.push(response); //its ok here too
      }).catch(err =&gt;{
          console.log(err);
          reject(err);
      });
      console.log(responseArray); //nothing in array here
      resolve(responseArray);
     });
   }
  };
  </code></pre>