How do I make Google SignIn's redirect URL Dynamic?

I’m using Google Sign In inside Login page.
And onClick of the Sign In button I’m executing this code :point_down:


Here, the user should be redirected based on the user’s role.
This is my getUserDashboardAndId function

  getUserDashboardAndId: () => {
    //getUserData is the API call made to supabse, which returns some data. => {
    }) => {
       storeValue("loggedin_user", user[0]);
    const role =;
    if (role === "Employee") {
      return "employeedashboard-63d89abcb8b46679d190f4c8";
    } else if (role === "Reviewer") {
      return "reviewerdashboard-63e24e094fc63a0df6b867ae";
    } else {
      return "admindashboard-63d89abcb8b46679d190f4e5";

Error: On Signing In I’m getting TypeError: Cannot read properties of undefined (reading ‘role’)
Seems like the code is running first before login data gets stored inside Store.

My only concern is to redirect this URL to the respective dashboards based on the user’s role.

Hey, here you are using async actions and expecting sync results. Check out this article - How do I use Async/Await in Javascript?

Also, keep in mind - storeValue is an async function

1 Like