title: Use Promise to get the return data
body: <p>I am trying to pull the data from realms and then process it using the native call. Once I get the processed data I further filter it in react native code and then give the return data. But till the time I complete all the activity the return parameter is already executed. Please have a look at the below code snippet:</p>
  
  <pre><code>async getArray() {
    realm = await this.getRealMObject();
    favoriteArray = realm.objects(constants.SCHEMA_SAVE);
    return favoriteArray;
  }
  
  async getLevel() {
    let low = 'false';
    let favoriteArray = await this.getAllArray();
    let getDetails = [];
    if (favoriteArray.length &gt; 0) {
      for (var y in favoriteArray) {
        NativeModules.Get.GetAsyncTask(
          brd[0].toUpperCase(),
          strChk, '1',
          kResponse =&gt; {
            if (Platform.OS == 'ios') {
              getDetails = kResponse;
            } else {
              getDetails = JSON.parse(kResponse);
            }
            for (let x = 0; x &lt; getDetails.length; x++) {
              const strLevel = this.getPercentage(getDetails[x]);
              if (strLevel &lt;= 20) {
                low = true;
              }
            }
          });
      }
    } else {
      low = false;
    }
    return low;
  }
  </code></pre>
  
  <p>Above is the code snippet. So when I call <code>getlevel()</code> before the processing is finished I get the return <code>low</code> value.</p>
  
  <p>How can I handle, this? I want the data to be processed and then get the return value.</p>