Skip to content

Commit

Permalink
State in post request should be evaluated at the time of the action
Browse files Browse the repository at this point in the history
  • Loading branch information
mrniket committed May 1, 2018
1 parent cc4f9f6 commit 2a2b4fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions game_frontend/src/redux/api/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ const getCSRFToken = action$ =>
.map(response => response.csrfToken)
)

const postOperator = (url, body) => csrfToken$ => (
const postOperator = (url, body) => csrfToken$ =>
csrfToken$.mergeMap(csrfToken =>
ajax.post(url, body, {
ajax.post(url, body(), {
withCredentials: true,
'X-CSRFToken': csrfToken
})
)
)

const post = (url, body) =>
pipe(
Expand Down
2 changes: 1 addition & 1 deletion game_frontend/src/redux/features/Editor/epics.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const postCodeEpic = (action$, store, { api }) =>
ofType(types.POST_CODE_REQUEST),
api.post(
`/players/api/code/${store.getState().game.id}/`,
{ code: store.getState().editor.code }
() => ({ code: store.getState().editor.code })
),
map(response => actions.postCodeReceived()),
catchError(error => Observable.of({
Expand Down

0 comments on commit 2a2b4fe

Please sign in to comment.