-
Notifications
You must be signed in to change notification settings - Fork 0
performAction
Michael Niday edited this page Jun 5, 2018
·
4 revisions
-
action(string): you must specify these actions first in your resource_config file -
options(object)
- itemId: In POST /contacts/:id this would populate the
:id - data (object): In POST /contacts this would be body request data
- filters (Immutable.Map): In GET /contacts this would be query params used in fetching the resource
- onSuccess (Function): Callback that gets called when ApiClient promise resolves
- onError (Function): Callback that gets called when request errors
// In a React component
...
handleGetPerson = (url) => {
this.props.people.performAction('fetch', {
itemId: idFromUrl(url),
responseStrategy: 'ignore',
onSuccess: ({data}) => {
this.setState({selectedPersonId: data.id})
this.fetchPlanet(data.homeworld)
}
})
}
...
export default entities({people: {type: 'people'}})(Component)
Here people is both the name of the container prop provided to Component and the record type defined in records.js