My app uses React Router in App.js like so:
<Router>
<Switch>
<Route exact path="/">
<Home />
</Route>
<Route path="/login">
<LoginWrapper />
</Route>
<PrivateRoute path="/dashboard">
<Dashboard />
</PrivateRoute>
In my LoginWrapper component, I call a login function like so:
doLogIn = (email, password) => {
Auth.signIn(email, password).then(user => {
localStorage.setItem('jwt', user.signInUserSession.accessToken.jwtToken);
});
// call /get-redirect endpoint here, but somehow get React Router
// in the parent component to see it + render the right component?
}
After the signIn is complete, I want to call a /get-redirect endpoint in my application. That function always returns a 200, with the JSON body saying where to redirect (in response.message).
After signing in, how can I call that /get-redirect endpoint, and have React Router in my App.js render the appropriate component?