2017-02-24 16 views
1

http取得要求を出していますが、Suppliedパラメータが呼び出しターゲットのシグネチャと一致しません。どのように私はこれを修正するのですか?指定されたパラメータが呼び出しターゲットのシグネチャと一致しません - 角度2

getFood(id){ 
     let headers = new Headers({ 'Authorization': 'Bearer ' + this.auth.token }); 
     let options = new RequestOptions({ headers: headers }); 
     return this.http.get('http://localhost:8000/routes/food_serve/v1/foodlist/'+id+'/food', options) 
      .map((response:Response) => response.json()); 

    } 
+0

に何の戻り値の型を持っていないとして観測を返すので、多分それは問題だ、あなたはこれらの輸入 'インポート{HTTP、RequestOptionsを持っていますか、Headers、Response}を '@ angular/http'から取得します。インポート 'rxjs/add/operator/map'; '? – yurzui

+0

@yurzuiはい私はそれらをインポートしました – XamarinDevil

+0

正確にどの行がエラーを投げていますか? – yurzui

答えて

2

あなたはバージョン2を使用している場合http.getあなたが機能

import { Response } from '@angular/http'; 
import { Observable } from 'rxjs/Rx'; 

getFood(id): Observable<Response> { 
    let headers = new Headers({ 'Authorization': 'Bearer ' + this.auth.token }); 
    let options = new RequestOptions({ headers: headers }); 
    return this.http.get('http://localhost:8000/routes/food_serve/v1/foodlist/'+id+'/food', options) 
     .map((response:Response) => response.json()); 

} 
関連する問題