init : getPersonne dans favoris

This commit is contained in:
Thomas Cardon 2022-03-02 16:48:32 +01:00
parent 829c8333f6
commit b3987b0255
3 changed files with 12 additions and 4 deletions

View File

@ -11,11 +11,19 @@ export class FavorisUserComponent implements OnInit {
personneConnectee : any; personneConnectee : any;
constructor(private apiBackService : ApiBackService,private tokenService : TokenService) { } constructor(private apiBackService : ApiBackService,private tokenService : TokenService) {
}
ngOnInit(): void { 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); console.log(this.personneConnectee);

View File

@ -70,7 +70,7 @@ export class ApiBackService {
} }
getPersonneById(id: number | null) { getPersonneById(id: any) {
return this.httpClient.get<any[]>(`${environment.apiUrl}/user/${id}`); return this.httpClient.get<any[]>(`${environment.apiUrl}/user/${id}`);
} }
} }

View File

@ -23,7 +23,7 @@ export class TokenService {
const token = this.getToken(); const token = this.getToken();
if(token) { if(token) {
const decodedToken = jwt_decode<any>(token); const decodedToken = jwt_decode<any>(token);
const userId = decodedToken.sub; const userId = decodedToken.userId;
console.log(userId); console.log(userId);
return userId; return userId;