I have a really simple http request.
My Front end:
<button mat-button (click)="onSubmit()">Login</button>
My onSubmit():
onSubmit() {
this.personService.getPersonByName().subscribe(person => {
console.log('Person', person);
});
My PersonService getPersonByName():
private personURL = 'http://localhost:3000/api/persons'
constructor(private http: HttpClient) { }
getPersonByName(): Observable<Person> {
let params = new HttpParams().set('username', 'SwaX');
return this.http.get<Person>(this.personURL, { params });
}
What i get:
Why do i get 3 Objects instead of 1?

This is a problem with your API, not Angular. You're not filtering down your response before sending it back over the wire. You could fix it on the API side and have it return a single object instead of an array of objects or you could filter the object out of the response in your service's getPersonByName() method using map -