getStepList(): Observable<JSON> {
this.headers = new Headers();
this.headers.append('Content-Type', 'application/json; charset=utf-8');
let options = new RequestOptions({
method: RequestMethod.Post,
url: "FeedbackMaster.aspx/getStepList",
headers: this.headers,
body:{log:this.login}
});
return this._http.request(new Request(options)).retry(2)
.map((response: Response)=>this.extractData(response))
.do(data => {this.temp=data, console.log('getStepList:'+ JSON.stringify(JSON.parse(this.temp.d)))})
.catch(this.handleError);
}
extractData(res: Response) {
let body = res.json();
return body || { }; //<--- not wrapped with data
}
handleError(error: any) {
console.error('An error occurred', error);
return Promise.reject(error.message || error);
}
.......................................................................................................
Error
[ts]
Type 'Observable<void>' is not assignable to type 'Observable<JSON>'.
Type 'void' is not assignable to type 'JSON'.
What is wrong in my code?
[ts] Type 'Observable<void>' is not assignable to type 'Observable<JSON>'. Type 'void' is not assignable to type 'JSON'. What is wrong in my code?
Type 'Observable<any>' is not assignable to type 'Products []'. Property 'length' is missing in type 'Observable<any>'
....................................................................................................... [ts] Type 'Observable<void>' is not assignable to type 'Observable<JSON>'. Type 'void' is not assignable to type 'JSON'. What is wrong in my code? Show activity on this post.
Bookmark this question. Show activity on this post. ....................................................................................................... [ts] Type 'Observable<void>' is not assignable to type 'Observable<JSON>'. Type 'void' is not assignable to type 'JSON'.
.map()
needs to return something, for example:
.map((response: Response) => { this.extractData(response); return response.json(); })
The return response.json()
yields Observable<JSON>
. Without returning anything from .map()
it becomes Observable<void>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With