Get auth data in router

I want to do auth via any service. My backend redirects me to frontend with jwt token. How should I get token from query params? I tried this route:

{
      path: '/auth',
      name: 'auth',
      redirect: to => {
        const { query: { token } } = to;
        if(token) store.dispatch('user/update', token);

        return '/';
      }
    }

But my dispatch contains request to api(for getting user data by token) and I need to use await, but when I write async before to, my route breaks.

Do you have control over the code of the backend?

Yes, a backend is my own too.

Ok, then I can tell you how I did it.

I have an api that handles auth, too. It has two routes for authentication.

Login:
POST /auth/login

Request body (application-json)

{
  "username": "theusername",
  "password': "thepassword"
}

Response body (application-json)

{
  "token": "abcd...",
  "refresh_token": 'afdjflkad..."
}

Refresh Token:
POST /auth/refresh

Request body (application-json)

{
  "refresh_token": 'afdjflkad..."
}

Response body (application-json)

{
  "token": "abcd...",
  "refresh_token": 'afdjflkad..."
}

Now in vue js I first let the user login with it’s credential, make a call to /auth/login and save the tokens from the response in the local storage. The point is: no redirekt.

I am using axios in vue and interceptors, so if I do a request, that needs a bearer token and the server responses 401, because the token is expired, I will make an additional refresh request to get a new token and then try the previous request again with the new token.

So I try to avoid to redirekt to the api and then back to the frontend. The user should never get directly get into contact with the api at all. Everything should be handled in the vue app.