Reputation: 7719
I have an angular 2 application. Upgraded from rxjs-5.0.0-beta.12
to rxjs-5.1.0
but now below this.http.get(...).map()
shows an error.
Supplied parameters do not match any signature of call target
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 => {
});
}
}
}
Error only occurs when adding the .map()
, did something change in the release?
Full IDE message:
[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
Upvotes: 0
Views: 999
Reputation: 29635
Observable.map takes only one callback function as parameter.
You should put the error callback in subscribe()
or use catch
if(headers) {
return this.http.get(this.baseUrl+url, {headers: headers}).map(response => {
}).catch(err=>{});
}
Upvotes: 3