Skip to content

redux-resource-fetch #276

Description

@jamesplease

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: JakeChampion/fetch#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)
  );

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ecosystem extraThis relates to something in the Redux Resource ecosystem, and not the core library

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions