Skip to content
This repository was archived by the owner on Aug 18, 2026. It is now read-only.
This repository was archived by the owner on Aug 18, 2026. It is now read-only.

Trouble with the AuthService > refreshToken #2

Description

@kosuh

Hello,

I allow myself to contact you because after setting up your solution everything works fine except that I block on the method refreshToken AuthService

When I make my request in http to retrieve the new token, the return executes before the request replies.

I am not very experienced in Angular so I think the solution is not difficult.

AuthService.ts

refreshToken(): Observable<any> {
		let url: string = environment.API + "/auth/token/refresh";
		let jwt = JSON.parse(localStorage.getItem('jwt'));
		const query = {
			'refresh_token': jwt.refresh_token
		}
		this.http.post(url, query).pipe(
			map((newtoken) => {
				localStorage.setItem('jwt', JSON.stringify(newtoken));
				jwt = JSON.parse(localStorage.getItem('jwt'));
				this.authTokenNew = jwt.token;
		}));

		this.currentToken = this.authTokenNew;

		return observableOf(this.authTokenNew).pipe(delay(200));
	}

Do you have a solution for me please ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions