我有這樣住宅 '數據' 上類型不存在 'HttpEvent <Customer>'
- api.service一個設置(包HttpClient的模塊)
- customer.service
的api服務得到看起來像這樣:
get<T>(url: string, options?) {
return this.httpClient.get<T>(this.apiUrl + url, this.getOptions(options));}
在我的customer.service我有:
private fetchCustomer(access_token: String): Observable<Customer> {
const options = { headers: new HttpHeaders({ Authorization: 'Bearer ' + access_token }) };
return this.http
.get<Customer>('customers/me', options)
.map(res => {
const customer = res.data;
customer.access_token = access_token;
return customer;
})
.catch(this.handleError.bind(this));
}
,它給我這個錯誤:
[ts]
Property 'data' does not exist on type 'HttpEvent<Customer>'.
Property 'data' does not exist on type 'HttpSentEvent'.
在你fetchCustomer方法確實this.http參閱您的API服務?或http客戶端 – LLai
它使用我的api服務 – Mackelito