-
Notifications
You must be signed in to change notification settings - Fork 293
Fetching data
Ruslan Kyba edited this page Mar 6, 2017
·
10 revisions
ARc's data fetching mechanics are mainly based on isomorphic-fetch and redux-saga packages.
isomorphic-fetch is responsible for calling your API methods on server and clint side when redux-saga is Redux middlwear which simplifies process of connecting API with redux store.
In order to be able to fetch data on server side you need to add static method to your component's container with the name matching HTTP method you want to manage (GET, POST, etc.) in lower case. For example:
class SamplePageContainer extends Component {
static get({ store }) {
return new Promise((resolve, reject) => {
store.dispatch(postListReadRequest({ _limit: 15 }, resolve, reject))
})
}
render() {
return <SamplePage />
}
}
As you can see this method should return Promise as result.
Special thanks to @kybarg and @protoEvangelion for helping to write this Wiki. Please, feel free to edit/create pages if you think it might be useful (also, see #33)