parent
79dc1f2dc8
commit
350dadb63e
|
@ -17,7 +17,7 @@ export class HeroService {
|
||||||
private headers = new Headers({'Content-Type': 'application/json'});
|
private headers = new Headers({'Content-Type': 'application/json'});
|
||||||
// #enddocregion update
|
// #enddocregion update
|
||||||
// #docregion getHeroes
|
// #docregion getHeroes
|
||||||
private heroesUrl = 'app/heroes'; // URL to web api
|
private heroesUrl = 'api/heroes'; // URL to web api
|
||||||
|
|
||||||
constructor(private http: Http) { }
|
constructor(private http: Http) { }
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ export class HeroService {
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
// #enddocregion catch
|
// #enddocregion catch
|
||||||
}
|
}
|
||||||
// #enddocregion getHeroes
|
|
||||||
|
|
||||||
|
// #enddocregion getHeroes
|
||||||
getHero(id: number): Promise<Hero> {
|
getHero(id: number): Promise<Hero> {
|
||||||
return this.getHeroes()
|
return this.getHeroes()
|
||||||
.then(heroes => heroes.find(hero => hero.id === id));
|
.then(heroes => heroes.find(hero => hero.id === id));
|
||||||
|
@ -71,11 +71,11 @@ export class HeroService {
|
||||||
}
|
}
|
||||||
// #enddocregion put, update
|
// #enddocregion put, update
|
||||||
|
|
||||||
// #docregion handleError
|
// #docregion getHeroes, handleError
|
||||||
private handleError(error: any): Promise<any> {
|
private handleError(error: any): Promise<any> {
|
||||||
console.error('An error occurred', error); // for demo purposes only
|
console.error('An error occurred', error); // for demo purposes only
|
||||||
return Promise.reject(error.message || error);
|
return Promise.reject(error.message || error);
|
||||||
}
|
}
|
||||||
// #enddocregion handleError
|
// #enddocregion getHeroes, handleError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue