Possible unhandled promise rejection
<p>I'm trying to reject a promise as explained in the documentation of the API of the framework I'm using (Apollo stack) but it doesn't show an example, it only states just that I have to reject the promise if there is an error, and I'm trying to get rid of the annoying YellowBox message "Warning: Possible unhanded promise rejection" when trying my application without an internet connection.</p>

<p>My method actually works, it goes to the catch and it shows the error message, but i keep getting the annoying YellowBox message, that's what I'm trying to fix.</p>

<p>first thing I did, goes to the catch, as expected, but it shows a YellowBox message <code>Warning: Possible unhandled promise rejection...</code></p>

<pre><code>return client.query({ query: gql`...`, }).then((data) =&gt; {
    console.log(data);
    data;
}).catch((error) =&gt; {
    console.log(error);
    error;
});
</code></pre>

<p>Last thing I've tried:</p>

<pre><code>var promise = new Promise(function(resolve, reject) {
  //async call, client.query(..) "returns a promise that should be rejected
  //if there is an error message..."
  client.query({ query: gql`...`, }).then(({data}) =&gt; {
    console.log(data);
    resolve(data);
  }).catch((error) =&gt; {
    console.log(error); // goes right here, works.
    reject(error.message);
  });
});
//just trying this out
promise.then((data) =&gt; {
  console.log(data);
}).catch((error) =&gt; {
  console.log(error); 
});
</code></pre>

<p>Also, adding the tag Meteor because couldn't find Apollo but it's pretty much the same thing.</p>

<p>Trying more stuff as suggested in the answers and comments:</p>

<pre><code>var promise = new Promise(function(resolve, reject) {
  client.query({
    query: gql`...`,
  }).then(({data}) =&gt; {
    console.log(data);
    resolve(data);
  }).catch((error) =&gt; {
    reject(error.message);
  });
}, (error) =&gt; {
  console.log(error);
});
</code></pre>

<p>another:</p>

<pre><code>var callback = {
  success: function(data) {
    console.log("SUCCESS");
  },
  error: function(data) {
    console.log("ERROR");
  }
};

var promise = new Promise(function(resolve, reject) {
  client.query({
    query: gql`...`,
  }).then(({data}) =&gt; {
    console.log(data);
    resolve(data);
  }).catch((error) =&gt; {
    console.log(error);
    reject(error.message);
  });
  return promise;
});
promise.then(callback.success, callback.error);
</code></pre>

<p>another:</p>

<pre><code>client.query({
  query: gql`...`,
}).then(({data}) =&gt; {
  console.log(data);
}, (error) =&gt; {
  console.log(error);
});
</code></pre>

<p>ApolloStack: <a href="http://docs.apollostack.com/apollo-client/network.html" rel="nofollow">http://docs.apollostack.com/apollo-client/network.html</a> it says, that returns a promise that should be rejected if an error occurs.</p>

<p>YellowBox detects unhandled promises and such things and throws warnings.  </p>