2017-03-13 11 views
0

私は角度2のアプリケーションを持っています。 rxjs-5.0.0-beta.12からrxjs-5.1.0にアップグレードされましたが、現在はthis.http.get(...).map()未満がエラーを示しています。Observable.map - 指定されたパラメータが呼び出し対象のシグネチャと一致しません

指定されたパラメータは、コールのターゲットのいずれかの署名と一致していない.map()を追加するとき

import { Http, Headers } from '@angular/http'; 
import { Observable } from 'rxjs/Observable'; 
import 'rxjs/add/operator/map'; 
import 'rxjs/add/operator/catch'; 

export class BaseService { 
    private baseUrl: string = 'http://someserver:8080/somedb'; 

    constructor(public http: Http) {} 

    doGet(url: string, headers?: Headers): Observable<any> { 
     if(headers) { 
      return this.http.get(this.baseUrl+url, {headers: headers}).map(response => { 

      }, err => { 

      }); 

     } 
    } 

} 

エラーのみ発生し、リリースの中で何かが変化しましたか?

全IDEメッセージ:

[ts] Supplied parameters do not match any signature of call target. 
Applies a given project function to each value emitted by the source 
Observable, and emits the resulting values as an Observable. 

<span class="informal">Like Array.prototype.map(), 
it passes each source value through a transformation function to get 
corresponding output values.</span> 

<img src="./img/map.png" width="100%"> 

Similar to the well known Array.prototype.map function, this operator 
applies a projection to each value and emits that projection in the output 
Observable. 

@example <caption>Map every every click to the clientX position of that click</caption> 
var clicks = Rx.Observable.fromEvent(document, 'click'); 
var positions = clicks.map(ev => ev.clientX); 
positions.subscribe(x => console.log(x)); 

@see {@link mapTo} 
@see {@link pluck} 

@return {Observable<R>} An Observable that emits the values from the source 
Observable transformed by the given project function. 
@method map 
@owner Observable 

(property) Observable<Response>.map: <T, R>() => any 

答えて

3

Observable.mapは、パラメータとして一つだけコールバック関数をとります。 あなたはsubscribe()でエラーコールバックを置くか、まだ同じエラーcatch

if(headers) { 
      return this.http.get(this.baseUrl+url, {headers: headers}).map(response => { 

      }).catch(err=>{}); 

     } 
+0

を使用する必要があり、私はそれが実際にはコンパイル時のエラー – Ivaro18

+0

ちょうどIDEエラーだかどうかは、その後package.jsonを追加することができますチェックしましょうか? –

+1

私の悪い、私はあなたの答えを受け入れるでしょう、問題は私のVisual Studioコードであることが判明それはそれが好きではありません。 getコールが機能する – Ivaro18

関連する問題