Skip to content

Commit

Permalink
Fixed onRequest for fsa actions
Browse files Browse the repository at this point in the history
  • Loading branch information
klis87 committed May 23, 2020
1 parent 8935f12 commit f53088d
Showing 1 changed file with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,19 @@ const maybeCallOnRequestInterceptor = (action, config, store) => {
config.onRequest &&
(!action.meta || action.meta.runOnRequest !== false)
) {
if (action.request) {
return {
...action,
request: config.onRequest(payload.request, action, store),
};
}

return {
...action,
request: config.onRequest(payload.request, action, store),
payload: {
...action.payload,
request: config.onRequest(payload.request, action, store),
},
};
}

Expand All @@ -78,9 +88,19 @@ const maybeCallOnRequestMeta = (action, store) => {
const payload = getActionPayload(action);

if (action.meta && action.meta.onRequest) {
if (action.request) {
return {
...action,
request: action.meta.onRequest(payload.request, action, store),
};
}

return {
...action,
request: action.meta.onRequest(payload.request, action, store),
payload: {
...action.payload,
request: action.meta.onRequest(payload.request, action, store),
},
};
}

Expand Down

0 comments on commit f53088d

Please # to comment.