Skip to content

Commit 62b87f1

Browse files
committed
readme fixes
1 parent ee17b8a commit 62b87f1

File tree

1 file changed

+81
-81
lines changed

1 file changed

+81
-81
lines changed

README.md

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This add on attemps to solve 2 things:
2727
1. Reduce boilerplate by auto dispatching Request, Success, and Failure Events
2828
2. Be FSA Compliant
2929

30-
In order to be FSA Compliant, most of the information is stored in the `meta` object.
30+
In order to be FSA Compliant, most of the information is stored in the `meta` object.
3131

3232

3333
# The Simple Way (`{string} endpoint`)
@@ -36,7 +36,7 @@ In order to be FSA Compliant, most of the information is stored in the `meta` ob
3636

3737
Wraps an action creator so that its return value is the payload of a Flux Standard Action, and also creates multiple actions types that can be handled via middleware (Request, Success, and Failure Types).
3838

39-
The parameters you pass to your action are **verb dependant**
39+
The parameters you pass to your action are **verb dependant**
4040

4141
Also adds `meta` data, such as the `method` and `endpoint` to be used where you see fit.
4242

@@ -49,16 +49,16 @@ Example:
4949
let createContact = createAPIAction('CREATE_CONTACT', 'POST', '/contacts' );
5050

5151
expect(createContact( {name: "James Kusachi"} )).to.deep.equal({
52-
type: 'CREATE_CONTACT',
53-
payload: {name: "James Kusachi"},
54-
meta: {
55-
api: true,
56-
method: 'POST',
57-
endpoint: '/contacts',
58-
types: [
59-
'CREATE_CONTACT_REQUEST',
60-
'CREATE_CONTACT_SUCCESS',
61-
'CREATE_CONTACT_FAILURE',
52+
"type": "CREATE_CONTACT",
53+
"payload: {name": "James Kusachi"},
54+
"meta": {
55+
"api": true,
56+
"method": "POST",
57+
"endpoint": "/contacts",
58+
"types": [
59+
"CREATE_CONTACT_REQUEST",
60+
"CREATE_CONTACT_SUCCESS",
61+
"CREATE_CONTACT_FAILURE",
6262
]
6363
}
6464
});
@@ -70,33 +70,33 @@ redux-actions will automatically set ```action.error``` to true.
7070

7171
The following are **Verb Based Examples** so you can see how to use your actions
7272

73-
### GET
73+
### GET
7474
```js
7575
let getItems = createAPIAction('ITEMS', 'GET', '/items' );
7676
getItems()
7777

7878
```
7979
there is no need to pass a payload to your action, as its a `GET` request
8080

81-
*Auto Generated Action Types*
82-
- `ITEMS_GET_REQUEST`
83-
- `ITEMS_GET_SUCCESS`
81+
*Auto Generated Action Types*
82+
- `ITEMS_GET_REQUEST`
83+
- `ITEMS_GET_SUCCESS`
8484
- `ITEMS_GET_FAILURE`
8585

86-
**Sample**
86+
**Sample**
8787

8888
```json
8989
{
90-
type: 'ITEMS',
91-
payload: {},
92-
meta: {
93-
api: true,
94-
method: 'GET',
95-
endpoint: '/items',
96-
types: [
97-
'ITEMS_GET_REQUEST',
98-
'ITEMS_GET_SUCCESS',
99-
'ITEMS_GET_FAILURE'
90+
"type": "ITEMS",
91+
"payload": {},
92+
"meta": {
93+
"api": true,
94+
"method": "GET",
95+
"endpoint": "/items",
96+
"types": [
97+
"ITEMS_GET_REQUEST",
98+
"ITEMS_GET_SUCCESS",
99+
"ITEMS_GET_FAILURE"
100100
]
101101
}
102102
}
@@ -109,33 +109,33 @@ there is no need to pass a payload to your action, as its a `GET` request
109109
let createItem = createAPIAction('ITEMS', 'POST', '/items' );
110110
createItem({name: "James Kusachi"});
111111
```
112-
In a case where you `POST` new data, you dont need to specify an id, but you do need to pass data.
112+
In a case where you `POST` new data, you dont need to specify an id, but you do need to pass data.
113113
Any data passed as the first parameter will be treated as the payload to be sent across.
114114

115-
*Auto Generated Action Types*
116-
- `ITEMS_POST_REQUEST`
117-
- `ITEMS_POST_SUCCESS`
115+
*Auto Generated Action Types*
116+
- `ITEMS_POST_REQUEST`
117+
- `ITEMS_POST_SUCCESS`
118118
- `ITEMS_POST_FAILURE`
119119

120-
**Sample**
120+
**Sample**
121121

122122
```json
123123
{
124-
type: 'ITEMS',
125-
payload: {
126-
name: "James Kusachi"
124+
"type": "ITEMS",
125+
"payload": {
126+
"name": "James Kusachi"
127127
},
128-
meta: {
129-
api: true,
130-
method: 'POST',
131-
endpoint: '/sample',
132-
types: [
133-
'ITEMS_POST_REQUEST',
134-
'ITEMS_POST_SUCCESS',
135-
'ITEMS_POST_FAILURE'
128+
"meta": {
129+
"api": true,
130+
"method": "POST",
131+
"endpoint": "/sample",
132+
"types": [
133+
"ITEMS_POST_REQUEST",
134+
"ITEMS_POST_SUCCESS",
135+
"ITEMS_POST_FAILURE"
136136
]
137137
}
138-
}
138+
}
139139
```
140140

141141

@@ -146,36 +146,36 @@ let updateItem = createAPIAction('ITEMS', 'PUT', '/items' );
146146
updateItem(15, {name: "Ronald McDonald"});
147147

148148
```
149-
In the event of an `UPDATE`, you generally need to specify 2 pieces
149+
In the event of an `UPDATE`, you generally need to specify 2 pieces
150150
* id of item you are updating
151151
* the data you want to update with
152152

153153
In this case, we are updating primary item `15` with a new object
154154

155-
*Auto Generated Action Types*
156-
- `ITEMS_PUT_REQUEST`
157-
- `ITEMS_PUT_SUCCESS`
155+
*Auto Generated Action Types*
156+
- `ITEMS_PUT_REQUEST`
157+
- `ITEMS_PUT_SUCCESS`
158158
- `ITEMS_PUT_FAILURE`
159159

160-
**Sample**
160+
**Sample**
161161

162162
```json
163163
{
164-
type: 'ITEMS',
165-
payload: {
166-
name: 'james'
164+
"type": "ITEMS",
165+
"payload": {
166+
"name": "james"
167167
},
168-
meta: {
169-
api: true,
170-
method: 'PUT',
171-
endpoint: '/sample/10',
172-
types: [
173-
'ITEMS_PUT_REQUEST',
174-
'ITEMS_PUT_SUCCESS',
175-
'ITEMS_PUT_FAILURE'
168+
"meta": {
169+
"api": true,
170+
"method": "PUT",
171+
"endpoint": "/sample/10",
172+
"types": [
173+
"ITEMS_PUT_REQUEST",
174+
"ITEMS_PUT_SUCCESS",
175+
"ITEMS_PUT_FAILURE"
176176
]
177177
}
178-
}
178+
}
179179
```
180180

181181
### DELETE
@@ -187,25 +187,25 @@ updateItem(15);
187187
In the case of `DELETE`, you just need to specify the primary id of tha which you want to delete.
188188
No need to pass in any payload data, as that would get dropped anyways because of `DELETE`
189189

190-
*Auto Generated Action Types*
191-
- `ITEMS_DELETE_REQUEST`
192-
- `ITEMS_DELETE_SUCCESS`
190+
*Auto Generated Action Types*
191+
- `ITEMS_DELETE_REQUEST`
192+
- `ITEMS_DELETE_SUCCESS`
193193
- `ITEMS_DELETE_FAILURE`
194194

195-
**Sample**
195+
**Sample**
196196

197197
```json
198198
{
199-
type: 'ITEMS',
200-
payload: {},
201-
meta: {
202-
api: true,
203-
method: 'DELETE',
204-
endpoint: '/sample/5',
205-
types: [
206-
'ITEMS_DELETE_REQUEST',
207-
'ITEMS_DELETE_SUCCESS',
208-
'ITEMS_DELETE_FAILURE'
199+
"type": "ITEMS",
200+
"payload": {},
201+
"meta": {
202+
"api": true,
203+
"method": "DELETE",
204+
"endpoint": "/sample/5",
205+
"types": [
206+
"ITEMS_DELETE_REQUEST",
207+
"ITEMS_DELETE_SUCCESS",
208+
"ITEMS_DELETE_FAILURE"
209209
]
210210
}
211211
}
@@ -216,13 +216,13 @@ No need to pass in any payload data, as that would get dropped anyways because o
216216

217217
In cases where you need to customize the endpoint with more granularity, you can pass a `function` as the `endpoint` instead of a string. This gives you access to the payload so you can create dynamic endpoints based on the payload.
218218

219-
NOTE: When using the Advanced method, you only need to send a payload across. In the Simple version, parameter order is important (IE: for PUTs, first parameter is ID, second is payload, for POST the parameter is the payload).
219+
NOTE: When using the Advanced method, you only need to send a payload across. In the Simple version, parameter order is important (IE: for PUTs, first parameter is ID, second is payload, for POST the parameter is the payload).
220220

221221
For the advanced version, you only need to send the payload, and your endpoint will return dynamically based on your function.
222222

223-
examples:
223+
examples:
224224

225-
**GET Example**
225+
**GET Example**
226226

227227
```js
228228
const customEndpoint = (p) => {
@@ -235,7 +235,7 @@ getItems(10); //GET /tester/10/mctesterson
235235

236236
```
237237

238-
**POST Example**
238+
**POST Example**
239239

240240
```js
241241
const customEndpoint = (params) => {
@@ -247,7 +247,7 @@ const payload = { id: 10, name: 'james' };
247247
createItem(payload); //POST /user/10/ronald/james
248248
```
249249

250-
**PUT Example**
250+
**PUT Example**
251251

252252
```js
253253
const customEndpoint = (params) => {
@@ -259,7 +259,7 @@ const payload = { id: 10, name: 'james' };
259259
updateItem(payload); //PUT /user/10
260260
```
261261

262-
**DELETE Example**
262+
**DELETE Example**
263263

264264
```js
265265
const customEndpoint = ({id, accountID}) => {

0 commit comments

Comments
 (0)