/* GET heroes whose name contains search term */
searchHeroes(term: string): Observable {
  term = term.trim();

  // Add safe, URL encoded search parameter if there is a search term
  const options = term ?
   { params: new HttpParams().set('name', term) } : {};

  return this.http.get(this.heroesUrl, options)
    .pipe(
      catchError(this.handleError('searchHeroes', []))
    );
}