ajout getPersonnById ds service + ds favoris
This commit is contained in:
parent
bea5442dea
commit
7ac59372b2
12633
package-lock.json
generated
12633
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { ApiBackService } from 'src/app/services/api-back.service';
|
||||||
|
import { TokenService } from 'src/app/services/token.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-favoris-user',
|
selector: 'app-favoris-user',
|
||||||
@ -7,9 +9,16 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
})
|
})
|
||||||
export class FavorisUserComponent implements OnInit {
|
export class FavorisUserComponent implements OnInit {
|
||||||
|
|
||||||
constructor() { }
|
personneConnectee : any;
|
||||||
|
|
||||||
|
constructor(private apiBackService : ApiBackService,private tokenService : TokenService) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
|
this.personneConnectee = this.apiBackService.getPersonneById(this.tokenService.getCurrentUserId());
|
||||||
|
console.log(this.personneConnectee);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,4 +64,8 @@ export class ApiBackService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPersonneById(id : number | null){
|
||||||
|
return this.httpClient.get<any[]>(`${environment.apiUrl}/user/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ export class AuthService {
|
|||||||
|
|
||||||
return this.http.post(`${this.apiUrl}/signin`, body).pipe(
|
return this.http.post(`${this.apiUrl}/signin`, body).pipe(
|
||||||
map((x: any) => {
|
map((x: any) => {
|
||||||
|
console.log(x);
|
||||||
|
|
||||||
console.log('Service : ', x.token);
|
console.log('Service : ', x.token);
|
||||||
// Modification à faire ici
|
// Modification à faire ici
|
||||||
|
@ -24,6 +24,8 @@ export class TokenService {
|
|||||||
if(token) {
|
if(token) {
|
||||||
const decodedToken = jwt_decode<any>(token);
|
const decodedToken = jwt_decode<any>(token);
|
||||||
const userId = decodedToken.sub;
|
const userId = decodedToken.sub;
|
||||||
|
console.log(userId);
|
||||||
|
|
||||||
return userId;
|
return userId;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user