fixes
This commit is contained in:
2971
tools/app/angular-tour-of-heroes/package-lock.json
generated
2971
tools/app/angular-tour-of-heroes/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,7 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
|
|
||||||
import { Hero } from './hero';
|
import { Hero } from './hero';
|
||||||
import { MessageService } from './message.service';
|
import { MessageService } from './message.service';
|
||||||
|
import { HEROES } from './mock-heroes'
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -14,12 +15,14 @@ export class HeroService {
|
|||||||
|
|
||||||
getHeroes(): Observable<Hero[]> {
|
getHeroes(): Observable<Hero[]> {
|
||||||
this.messageService.add('HeroService: fetched heroes');
|
this.messageService.add('HeroService: fetched heroes');
|
||||||
return this.http.get<Hero[]>(`/heroes`)
|
return of(HEROES)
|
||||||
|
// return this.http.get<Hero[]>(`/heroes`)
|
||||||
}
|
}
|
||||||
|
|
||||||
getHero(id: number): Observable<any> {
|
getHero(id: number): Observable<any> {
|
||||||
this.messageService.add(`HeroService: fetch hero id=${id}`);
|
this.messageService.add(`HeroService: fetch hero id=${id}`);
|
||||||
return this.http.get<Hero>(`/hero?id=${id}`)
|
return of(HEROES.find(hero => hero.id === id))
|
||||||
|
// return this.http.get<Hero>(`/hero?id=${id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHero(hero: Hero): Observable<any> {
|
updateHero(hero: Hero): Observable<any> {
|
||||||
|
Reference in New Issue
Block a user