Skip to content
Ruslan Kyba edited this page Mar 6, 2017 · 10 revisions

Main principles

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.

Clone this wiki locally