ajout getPersonnById ds service + ds favoris

This commit is contained in:
Thomas Cardon 2022-03-02 13:43:30 +01:00
parent bea5442dea
commit 7ac59372b2
5 changed files with 44 additions and 12607 deletions

12633
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ApiBackService } from 'src/app/services/api-back.service';
import { TokenService } from 'src/app/services/token.service';
@Component({
selector: 'app-favoris-user',
@ -7,9 +9,16 @@ import { Component, OnInit } from '@angular/core';
})
export class FavorisUserComponent implements OnInit {
constructor() { }
personneConnectee : any;
constructor(private apiBackService : ApiBackService,private tokenService : TokenService) { }
ngOnInit(): void {
this.personneConnectee = this.apiBackService.getPersonneById(this.tokenService.getCurrentUserId());
console.log(this.personneConnectee);
}
}

View File

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

View File

@ -45,6 +45,7 @@ export class AuthService {
return this.http.post(`${this.apiUrl}/signin`, body).pipe(
map((x: any) => {
console.log(x);
console.log('Service : ', x.token);
// Modification à faire ici

View File

@ -24,6 +24,8 @@ export class TokenService {
if(token) {
const decodedToken = jwt_decode<any>(token);
const userId = decodedToken.sub;
console.log(userId);
return userId;
} else {
return null;