File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 1
1
import * as types from 'constants/action-types' ;
2
+
2
3
export function fetchUngitConfig ( ) {
3
4
return dispatch => {
5
+ dispatch ( pending ( ) ) ;
4
6
// consider wrap API call in separate modules
5
7
// it will be easy to stub module's function when testing
6
8
fetch ( 'http://localhost:8448/ungit/config' )
7
9
. then ( response => response . json ( ) )
8
10
. then ( json => {
9
11
dispatch ( receiveUgitConfig ( json ) ) ;
12
+ } )
13
+ . catch ( e => {
14
+ dispatch ( apiError ( e . message ) ) ;
10
15
} ) ;
11
16
} ;
12
17
} ;
13
18
14
19
export function receiveUgitConfig ( ungitConfig ) {
15
20
return {
16
21
type : types . RECEIVE_UNGIT_CONFIG ,
17
- ungitConfig
22
+ payload : ungitConfig
23
+ } ;
24
+ } ;
25
+
26
+ export function pending ( ) {
27
+ return {
28
+ type : types . PATH_PAGE_PENDING
29
+ } ;
30
+ } ;
31
+
32
+ export function apiError ( message ) {
33
+ return {
34
+ type : types . PATH_PAGE_API_ERR ,
35
+ payload : message
18
36
} ;
19
- } ;
37
+ }
Original file line number Diff line number Diff line change 1
- export const RECEIVE_UNGIT_CONFIG = 'RECEIVE_UNGIT_CONFIG' ;
1
+ export const RECEIVE_UNGIT_CONFIG = 'RECEIVE_UNGIT_CONFIG' ;
2
+ export const PATH_PAGE_PENDING = 'PATH_PAGE_PENDING' ;
3
+ export const PATH_PAGE_API_ERR = 'PATH_PAGE_API_ERR' ;
You can’t perform that action at this time.
0 commit comments