Skip to content

Commit ba2ecd8

Browse files
committed
[spalenque] - #13144 * add error handler to core ui pull and get functions
1 parent 468bcdb commit ba2ecd8

1 file changed

Lines changed: 26 additions & 13 deletions

File tree

ui-core/ui/source/js/utils/actions.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export const getRequest =
4343
(
4444
requestActionCreator,
4545
receiveActionCreator,
46-
endpoint
46+
endpoint,
47+
errorHandler
4748
) => params => dispatch => {
4849
dispatch(requestActionCreator(params));
4950
const key = `${requestActionCreator().type}_${JSON.stringify(params || {})}`;
@@ -52,30 +53,42 @@ export const getRequest =
5253
let url = URI(endpoint).query(params).toString();
5354
console.log(`url is ${url}`);
5455
const req = http.get(url)
55-
.end(responseHandler(dispatch, json => {
56-
dispatch(receiveActionCreator({
57-
response: json
58-
}));
59-
}))
56+
.end(
57+
responseHandler(
58+
dispatch,
59+
json => {
60+
dispatch(receiveActionCreator({
61+
response: json
62+
}));
63+
},
64+
errorHandler
65+
)
66+
)
6067
schedule(key, req);
6168
};
6269

6370
export const putRequest = (
6471
requestActionCreator,
6572
receiveActionCreator,
6673
endpoint,
67-
payload
74+
payload,
75+
errorHandler
6876
) => params => dispatch => {
6977
let url = URI(endpoint).toString();
7078
dispatch(requestActionCreator(params));
7179
const req = http.put(url)
7280
.send(payload)
73-
.end(responseHandler(dispatch, json => {
74-
dispatch(receiveActionCreator({
75-
response: json
76-
}));
77-
}))
78-
81+
.end(
82+
responseHandler(
83+
dispatch,
84+
json => {
85+
dispatch(receiveActionCreator({
86+
response: json
87+
}));
88+
},
89+
errorHandler
90+
)
91+
)
7992
};
8093

8194
export const clearMessage = createAction('CLEAR_MESSAGE');

0 commit comments

Comments
 (0)