2
에 각 2 HTTP 서비스에 HTTP GET 요청을하는 방법 난 그냥 지금은 "Observables은 학습 해요! 헉! 관찰 가능한
그냥 대충이 튜토리얼 다음 코너 4. 간단한 GET 요청을 만들려고 약속을 마스터 완료 :. 내가rxjs/Observable
에서
Observable
를 가져올하려고 할 때
https://scotch.io/tutorials/angular-2-http-requests-with-observables
처음에 나는 컴파일 오류가 본질적 rxjs
컴파일 에러를 해결하기 위해지도 Observable<Response>
의 기능 아니었다 말하고, 그러나 가져 오기를 변화 있어요하지만 지금은 같은 얻을. 런타임 오류 ...
아래 응답을 처리하는 방법에 어떤 문제가 있습니까?
import { Injectable } from '@angular/core';
import { apiConfig } from '../../environments/environment';
import { Http, Response, Headers, RequestOptions } from '@angular/http';
import { APIRequest, APIResponse} from './api-objects';
import { Observable } from 'rxjs';
/**
* The BaseAPIService can be extended to provide base functionality for communicating to the API endpoint.
*/
@Injectable()
export class BaseAPIService {
private apiBase = apiConfig.base;
constructor(protected http: Http) { }
/**
* Sends an API request to the endpoint
*/
sendRequest(request: APIRequest): Observable<APIResponse> {
const options = new RequestOptions({ });
const fullUrl = `apiBase${request.url}`;
request.body = request.body || {};
return this.http.get(fullUrl).map((response: Response) => new APIResponse(response));
}
}
** 오류 세부 사항 **
this.http.get(...).map is not a function
at CoreAPIService.webpackJsonp.356.BaseAPIService.sendRequest (base-api.service.ts:25)
당신은 가져와야 다음 '가져 오기'rxjs가// 연산자/맵 추가 ',' – Haseoh