docs: fix logging upon search in example tutorial (#34806)

When no errors are thrown but empty array is returned we should log different message.

PR Close #34806
This commit is contained in:
Kristina Gocheva 2020-01-16 10:30:29 +02:00 committed by Matias Niemelä
parent 2f7857f0fb
commit b04c3cce09
1 changed files with 3 additions and 1 deletions

View File

@ -86,7 +86,9 @@ export class HeroService {
return of([]);
}
return this.http.get<Hero[]>(`${this.heroesUrl}/?name=${term}`).pipe(
tap(_ => this.log(`found heroes matching "${term}"`)),
tap(x => x.length ?
this.log(`found heroes matching "${term}"`) :
this.log(`no heroes matching "${term}"`)),
catchError(this.handleError<Hero[]>('searchHeroes', []))
);
}