Last active
March 23, 2018 09:47
-
-
Save jmas/169408a05ece27781a732c06ff95070d to your computer and use it in GitHub Desktop.
This file contains 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
const actions = createActionCreators({ | |
createJob: (payload, actions) => async dispatch => { | |
dispatch(actions.createJobRequest()) | |
const job = parseData(payload) | |
try { | |
const response = await api.jobs.create(job) | |
const body = await response.json() | |
if (response.status !== 200) { | |
throw new Error('Something went wrong') | |
} | |
dispatch(actions.createJobSuccess(body)) | |
} catch (error) { | |
dispatch(actions.createJobFailure(error)) | |
} | |
}, | |
createJobRequest: null, | |
createJobSuccess: null, | |
createJobFailure: null | |
}, 'jobs') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment