0

I am learning Angular. I am studying the angular.io/tutorial Tour of Heroes at https://stackblitz.com/angular/akkkxgnylgd. In app/hero.service.ts, there is this code:

@Injectable()
export class HeroService {

  private heroesUrl = 'api/heroes';  // URL to web api

   constructor(
    private http: HttpClient,
    private messageService: MessageService) { }

   /** GET heroes from the server */
   getHeroes (): Observable<Hero[]> {
    return this.http.get<Hero[]>(this.heroesUrl)
      .pipe(
        tap(heroes => this.log(`fetched heroes`)),
        catchError(this.handleError('getHeroes', []))
      );
  }

I was trying to investigate the call to /api/heroes. I turned on Chrome Developer Tools but could find no trace of any http calls to /api/heroes. How can I see the invocation of this URL?

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
Old Geezer
  • 14,854
  • 31
  • 111
  • 198
  • chrome dev tools often only shows the last part of a path. Is there an entry in the network tab for /heroes? – Gab Jan 29 '18 at 16:00
  • I filtered with the string `api` and the few requests shown does not include any `api/heroes`. – Old Geezer Jan 29 '18 at 16:11
  • 2
    https://angular.io/tutorial/toh-pt6#simulate-a-data-server: *This tutorial sample mimics communication with a remote data server by using the In-memory Web API module. After installing the module, the app will make requests to and receive responses from the HttpClient without knowing that the In-memory Web API is intercepting those requests, applying them to an in-memory data store, and returning simulated responses.* – JB Nizet Jan 29 '18 at 16:17
  • Thanks! (How do I close the question?) – Old Geezer Jan 29 '18 at 16:33

0 Answers0