redux-resource icon indicating copy to clipboard operation
redux-resource copied to clipboard

redux-resource-fetch

Open jamesplease opened this issue 7 years ago • 1 comments

Assuming #275 isn't closed in favor of #250, I should figure out the API for redux-resource-fetch, making the assumption that AbortController is supported.

The popular GitHub fetch polyfill may soon support this: https://github.com/github/fetch/issues/547


One possibility based on #275 :

// There is now only one method!
// The first argument determines which CRUD action it is
crudRequest('read', {
  url: '/pasta/pls',

  // These are options to configure the XHR request
  fetchOptions: {
    credentials: 'include',
    signal: abortController.signal
  },

  // These are properties that are merged into the start and end action by default
  actionProperties: {
    resourceName: 'books',
    mergeMeta: false
  },

  // same as what exists today
  transformData(data) {
   return body.data;
  }
})
  .then(
    (action, body) => dispatch(action)
    (action, err) => dispatch(action)
  );

jamesplease avatar Dec 07 '17 08:12 jamesplease

I'm going to close this as revisit. I'll open it when/if the abort polyfill lands.

jamesplease avatar Dec 08 '17 07:12 jamesplease