You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{
name: 'home',
url: '/',
component: DashboardContainer,
resolve: [
{
token: 'currentUser',
resolveFn: () => store.dispatch(getCurrentUser())
.then(res => {
if (!res.value) {
throw new Error('The current user could not be identified.');
}
// debugger;
})
.catch(err => {
// debugger;
})
}
],
onEnter: () => {
// debugger;
},
onExit: () => {
// debugger;
}
},
The getCurrentUser action looks like this:
return {
type: GET_CURRENT_USER,
payload: ax.request({
url: urlJoin(
config.portal.url,
'api/CommonApi/GetCurrentUser'
),
method: 'get',
maxRedirects: 0
}).then(res => {
// debugger;
if (!(res.data && res.data.clientId)) {
throw new Error('The current user could not be identified.');
}
}).catch(err => {
console.warn(err);
})
};
When walking through this transition, I get to the debugger in the getCurrentUser action and throw the Error because we didn't get the user back. This then executes the console.warn(err). Then it executes the then of the store.dispatch promise, which subsequently bubbles that error and hits the debugger in the catch of the store.dispatch promise.
However, even though the promise is being failed, the onEnter is still firing for this state and the state is being rendered; what I'd like to do is navigate to the Login state.
What did I do wrong here?
The text was updated successfully, but these errors were encountered:
UPDATE I stopped the entry of the state by executing throw new Error() inside the catch of the dispatch promise that was returned. Now I guess I just need to figure out how to redirect to the Login state when that happens.
I have a state configured like this:
The
getCurrentUser
action looks like this:When walking through this transition, I get to the
debugger
in thegetCurrentUser
action and throw theError
because we didn't get the user back. This then executes theconsole.warn(err)
. Then it executes thethen
of thestore.dispatch
promise, which subsequently bubbles that error and hits thedebugger
in thecatch
of thestore.dispatch
promise.However, even though the promise is being failed, the
onEnter
is still firing for this state and the state is being rendered; what I'd like to do is navigate to the Login state.What did I do wrong here?
The text was updated successfully, but these errors were encountered: