esse é o photo-list.component
constructor(
private photoService: PhotoService,
private activatedRoute: ActivatedRoute
){}
ngOnInit(): void {
const userName = this.activatedRoute.snapshot.params.userName;
this.photoService.listFromUser(userName).subscribe(photos => this.photos = photos);
}
Esse é o photo service
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Photo } from './photo';
const API = 'http://localhost:3000';
@Injectable({ providedIn: 'root' })
export class PhotoService {
constructor(private http: HttpClient){}
listFromUser(userName: string){
return this.http.get<Photo[]>(API + '/' + userName + '/photos');
}