score:13

Accepted answer

dispatch(login(formData)) returns undefined

Based on the docs for redux-thunk:

Any return value from the inner function will be available as the return value of dispatch itself.

So, you'd want something like

// thunk action creator returns a function
export function login(credentials) {
    return dispatch => {
        // update app state: requesting login
        dispatch(requestLogin(credentials))

        // try to log in
        apiClient.login(credentials)
            .then(authToken => dispatch(loginSuccess(authToken)))
            .catch(error => dispatch(loginFailure(error)))

        return promiseOfSomeSort;
    }
}

Related Query

More Query from same tag