Upon completing the Angular 2 Tour of heroes tutorial, I found myself pondering how to "retrieve the heroes" using a REST API.
If my API is hosted at http://localhost:7000/heroes
and returns a JSON list of "mock-heroes", what steps must I take to ensure a robust implementation?
I grasp that I should place this functionality within hero.service.ts
; specifically inside:
@Injectable()
export class HeroService {
getHeroes() {
return Promise.resolve(HEROES);
}
}
Yet, I am uncertain on initiating an HTTP GET request for this purpose, let alone executing it elegantly or stylishly.