Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redux-thunk question #1

Open
gozes opened this issue Feb 15, 2017 · 1 comment
Open

redux-thunk question #1

gozes opened this issue Feb 15, 2017 · 1 comment

Comments

@gozes
Copy link

gozes commented Feb 15, 2017

do I need use redux thunk with this middle where if my action creator calls store.dispatch/dispatch before calling an async function/arrow function?

@MaxOrelus
Copy link

MaxOrelus commented May 18, 2017

I did it with redux-thunk and it works well.

const actionSomething = () => (dispatch, getState) => {
  dispatch(/* pending like action type */);
  
  try {
    const data = async () => {
      return await fetch('URL').then(response => response.data)
        .catch(err => err);
    }
  } catch (err) {
    return dispatch(/* failed like action */);
  }

  return dispatch(/* success like action */);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants