Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. export function checkout() {
  2. return (dispatch, getState) => {
  3. return Promise.resolve()
  4. .then(() => {
  5. dispatch({ type: 'CHECKOUT_REQUEST' });
  6. const state = getState();
  7. if (!state.cart.items) {
  8. throw Error('No items to checkout');
  9. }
  10. })
  11. .then(() => (
  12. dispatch({ type: 'CHECKOUT_SUCCESS' })
  13. ))
  14. .catch(error =>
  15. dispatch({ type: 'CHECKOUT_FAILURE', error })
  16. )
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement