Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
feat(readme): document how to use query params
Browse files Browse the repository at this point in the history
  • Loading branch information
markbello authored and JamesSingleton committed Apr 17, 2020
1 parent a55421e commit 78da466
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,31 @@ These actions allow you to remove the associated data to a resource or collectio
### Query opts
iguazu-rest allows you to specify your query parameters as part of the opts passed to fetch. If they are used to filter a collection, make sure they are passed in this way instead of adding them directly to the url because it is necessary for proper caching. All of the resources get normalized, so iguazu-rest needs to a way to cache which resources came back for a set of query parameters.

```jsx
// Articles.jsx
import { connectAsync } from 'iguazu';
import { queryCollection } from 'iguazu-rest';

const Articles = ({ articles }) => (
<div>
{articles.map((article) => <Article key={article.id} article={article} />)}
</div>
);

function loadDataAsProps({ store: { dispatch } }) {
return {
articles: () => dispatch(queryCollection({
resource: 'articles',
opts: {
query: { limit: 10, sortBy: 'title' },
},
})),
};
}

export default connectAsync({ loadDataAsProps })(Articles);
```

## 🏆 Contributing

We welcome Your interest in the American Express Open Source Community on Github.
Expand Down

0 comments on commit 78da466

Please sign in to comment.