From b3987b02558f8dae6ef063abd9475946e71499a3 Mon Sep 17 00:00:00 2001 From: Thomas Cardon Date: Wed, 2 Mar 2022 16:48:32 +0100 Subject: [PATCH] init : getPersonne dans favoris --- src/app/pages/favoris-user/favoris-user.component.ts | 12 ++++++++++-- src/app/services/api-back.service.ts | 2 +- src/app/services/token.service.ts | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/pages/favoris-user/favoris-user.component.ts b/src/app/pages/favoris-user/favoris-user.component.ts index d389b1f..84adea7 100644 --- a/src/app/pages/favoris-user/favoris-user.component.ts +++ b/src/app/pages/favoris-user/favoris-user.component.ts @@ -11,11 +11,19 @@ export class FavorisUserComponent implements OnInit { personneConnectee : any; - constructor(private apiBackService : ApiBackService,private tokenService : TokenService) { } + constructor(private apiBackService : ApiBackService,private tokenService : TokenService) { + } ngOnInit(): void { - this.personneConnectee = this.apiBackService.getPersonneById(this.tokenService.getCurrentUserId()); + + this.apiBackService.getPersonneById(this.tokenService.getCurrentUserId()).subscribe( + resp =>{ + console.log(resp); + + this.personneConnectee = resp; + } + ); console.log(this.personneConnectee); diff --git a/src/app/services/api-back.service.ts b/src/app/services/api-back.service.ts index 7fce209..091ff2b 100644 --- a/src/app/services/api-back.service.ts +++ b/src/app/services/api-back.service.ts @@ -70,7 +70,7 @@ export class ApiBackService { } - getPersonneById(id: number | null) { + getPersonneById(id: any) { return this.httpClient.get(`${environment.apiUrl}/user/${id}`); } } \ No newline at end of file diff --git a/src/app/services/token.service.ts b/src/app/services/token.service.ts index 975f2e1..0529b5d 100644 --- a/src/app/services/token.service.ts +++ b/src/app/services/token.service.ts @@ -23,7 +23,7 @@ export class TokenService { const token = this.getToken(); if(token) { const decodedToken = jwt_decode(token); - const userId = decodedToken.sub; + const userId = decodedToken.userId; console.log(userId); return userId;