It’s very common to use Promise with Redux Thunk, it sounds complicated but it simply just returns Promise.resolve(data) after dispatching to the reducers. Here is an example in the redux action to signup new user, then on Client just uses then(result) to manipulate the screen logic


export const signUpUser = user => {
return dispatch => {
return fetch(`http://840dff44.ngrok.io/identity/authentication/signup`, {
method: "post",
headers: {
"Content-Type": "application/json",
Accept: "json"
},
body: JSON.stringify(user)
})
.then(res => res.json())
.then(data => {
if (data.isSuccess) {
dispatch({
type: TOKEN_UPDATED,
payload: data.token
});
dispatch({
type: TOKEN_EXPIRED_ON,
payload: data.tokenExpiredOn
});
}
return Promise.resolve(data);
})
.catch(error => {
console.log(error);
return Promise.reject(error);
});
};
};

Book online now &
SAVE
10%
On Your Ride

DOWNLOAD OUR APP
avada-taxi-phone-app

About the Author

Buy Avada Now

Subscribe Today

Subscribe to our monthly newsletter to receive all of the latest news and articles directly to your inbox.

Discussion

Leave A Comment

Testimonials

“Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.”

avada-taxi-testimonial-1

Mike Smith – Brooklyn, NY

Related Posts

If you enjoyed reading this, then please explore our other articles below:

Back to News

Don’t want to use the app?

No problem, book online or give us a call!

BOOK ONLINE
CALL TO BOOK
BOOK ONLINE
CALL TO BOOK