Wrapping fetch(), preserve promise-based API for outer function One of my react component's methods is using an async fetch() internally. After fetching the response from the server, it is being converted to JSON, then I perform a check on that JSON string. Finally, I return the result wrapped in a new promise. Here is the code:

fetchCalendarData(offset, length) {
    return fetch(this.props.Uri + '?offset=' + offset + '&amp;length=' + length)
    .then(response =&gt; response.json())
    .then((result) =&gt; {
        if (result.hasOwnProperty('redirect_to_login') &amp;&amp; result.redirect_to_login == true) {
            window.location.reload(window.globalAppState.base_url + "/login");
        }
        return Promise.resolve(result);
    })
    .catch(() =&gt; {
        return Promise.reject('FAILURE');
    });
}


When I call the method, I do it like this:

this.fetchCalendarData(0, 6).then((fetched_calendar_data) =&gt; {
    this.calendar_data = fetched_calendar_data;
});


The code works, but I am not familiar with promise based flow at all, and those 3 return statements look a little weird to me. I also read about the promise constructor antipattern but am not sure if that applies here. And, is it necessary to return the result wrapped in a new promise, at all?
but am not sure if that applies here. And, is it necessary to return
  the result wrapped in a new promise, at all?


Yes, that applies here. 

No, returning Promise.resolve() is not necessary. .then() returns a new Promise object. Use 

return result

within the function passed to .then().

Note, a value returned from .catch() results in a resolved Promise. Depending on how errors are handled an error could be thrown (withing {} of a function).

this.fetchCalendarData(0, 6).then((fetched_calendar_data) =&gt; {
    this.calendar_data = fetched_calendar_data;
});


should include the second parameter to .then() to handle potential error

.then((fetched_calendar_data)=&gt;{}, err=&gt;{/* handle error */})


given then Promise.reject() is returned from .catch(), or .catch() should be chained to .then()

.then((fetched_calendar_data)=&gt;{}
.catch(err=&gt;{/* handle error */})




fetchCalendarData(offset, length) {
  return fetch(this.props.Uri + '?offset=' + offset + '&amp;length=' + length)
  .then(response =&gt; response.json())
  .then(result =&gt; {
    if (result.hasOwnProperty('redirect_to_login') 
       &amp;&amp; result.redirect_to_login == true) {
         window.location.reload(window.globalAppState.base_url + "/login");
    }
    return result;
  })
  .catch(() =&gt; {
    throw new Error('FAILURE');
  });
}

this.fetchCalendarData(0, 6)
.then(fetched_calendar_data =&gt; {
  this.calendar_data = fetched_calendar_data;
})
.catch(err =&gt; console.error(err));