is it possible to await for dispatch action to end, so then, with that dispatched data before, I could use it in another function? Currently I have this type of code, but I believe I shouldn't pass request to action and I should use
const url = '/someurl';
return (dispatch) => {
apiClient.get(url)
.then((res) => {
dispatch({
type: FETCH_SESSION_INFO,
payload: res,
});
});
};
instead of:
const url = '/someUrl';
const request = apiClient.get(url);
return {
type: FETCH_SESSION_INFO,
payload: request,
};
I want to do this:
fetchSessionInfo.then(() => doSomething(session.something))
where session.something
is data we've just fetched from fetchSessionInfo
, but when trying to use 1st version I get an information, that fetchSessionInfo
is undefined