title: How to store API response in an array in javascript?
body: <p>I want to store api response inside an array so that I can search whether a particular email_address is already present or not</p>
  <pre><code>var emailArr = [];
    request(options, function (err, response, body) {
      var jsonBody = JSON.parse(body);
   
      if (err) {
        console.log(err);
      } else {
        for (var i = 0; i &lt; jsonBody.members.length; i++) {
          emailArr.push(jsonBody.members[i].email_address);
        }
        console.log(emailArr) // values are present
      }
    });
    console.log(emailArr); // empty array
  </code></pre>
  <p>The email array is consoling empty outside the request callback function but showing values inside,
  please tell me what can be the better solution</p>