Last active
March 31, 2017 11:07
-
-
Save Maarten88/6bd693da8b4ef0608698096de9bef9fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function postEffect(url: string, xsrfToken: string, data: any = {}) { | |
let response = await fetch(url, { | |
method: 'POST', | |
credentials: 'include', | |
headers: { | |
'Content-Type': 'application/json', | |
'X-XSRF-TOKEN': xsrfToken | |
}, | |
body: JSON.stringify(data) | |
}); | |
return response; | |
} | |
export const actionCreators = { | |
increment: (): AppThunkAction<KnownAction> => async (dispatch, getState) => { | |
dispatch({ type: Server.INCREMENT_COUNTER }); | |
var state = getState(); | |
let response = await postEffect('/incrementcounter', state.session.xsrfToken); | |
} | |
// [ ... other async actions ] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment