Created
January 19, 2016 09:11
-
-
Save lukemorton/6b377eda5c2e015954af 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
import { actions } from 'tarnish'; | |
function handleResponse(form) { | |
return function ({ token, errors }) { | |
if (errors) { | |
return actions.form.validationErrors(form, errors); | |
} else { | |
return actions.state.merge({ page: 'home#Index', token }); | |
} | |
}; | |
} | |
export function createSession(form) { | |
return actions.chain(actions.http.post('https://api/sessions.json', form.values), | |
handleResponse(form)); | |
} |
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
import { actions } from 'tarnish'; | |
export function createSession(form) { | |
const { errors, token } = actions.http.post('https://api/sessions.json', form.values); | |
if (errors.length) { | |
return actions.form.validationErrors(form, errors); | |
} else { | |
return actions.state.merge({ page: 'home#Index', token }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment