Skip to content

Commit e2bf2c0

Browse files
committed
Merge pull request #16 from lexich/helpers
Add helpers option
2 parents 4a2c9d2 + 8c8754f commit e2bf2c0

10 files changed

+395
-233
lines changed

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,32 @@ function (state, action) {
180180
}
181181
```
182182

183+
- @param **options.{endpoint}.helpers** - object
184+
```js
185+
{
186+
test: {
187+
url: "/api/test/:name/:id",
188+
helpers: {
189+
get(id, name) {
190+
return [{id, name}], {}]
191+
},
192+
post(id, name, data) {
193+
const {uuid} = this.getState().test;
194+
const urlparams = {id, name};
195+
const params = {body: {uuid, data}};
196+
return [urlparams, params];
197+
}
198+
}
199+
}
200+
}
201+
// using helpers
202+
rest.actions.test.get(1, "admin");
203+
// with callback
204+
rest.actions.post(1, "admin", {msg: "Hello"}, (err)=> {
205+
// end of action
206+
});
207+
```
208+
183209
#### reduxApi object
184210
`reduxApi` initializer returns non initialized object. You need to call `init` for initilize it.
185211
```js

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redux-api",
3-
"version": "0.6.3",
3+
"version": "0.6.4",
44
"main": "dist/redux-api.min.js",
55
"dependencies": {}
66
}

0 commit comments

Comments
 (0)