난 다음입니다 this tutorial (공식 주제 Angular2 "빠른 시작"튜토리얼) 그것의 끝에Angular2 - InMemoryWebApiModule을 사용하여 끝점을 구성 할 수있는 위치는 어디입니까?
, 대신 호출의 HTTP 요청 (... GET, POST, PUT 등 DELETE)의 부부가있다 실제 서버는 app.module.ts
이 라인을 사용하여 시뮬레이션 : 여기
// The HttpClientInMemoryWebApiModule module intercepts HTTP requests
// and returns simulated server responses.
// Remove it when a real server is ready to receive requests.
HttpClientInMemoryWebApiModule.forRoot(
InMemoryDataService, { dataEncapsulation: false }
)
응용 프로그램에 의해 만들어진 HTTP 요청의 예입니다
private heroesUrl = 'api/heroes'; // URL to web api
/** 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', []))
);
}
질문 다음을 구성 할 수있는 방법이 이 InMemoryDataService에서 예상되는 종단점은 무엇입니까? 예를 들어, URL을 api/heroes/getAll
으로 변경할 수 있습니다.
[this] (https://github.com/angular/in-memory-web-api)는 당신이 찾고있는 것이라고 생각합니다. –