Oh forgot to parse the return of the second get, here is the bug resolved:
import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/zip';
import 'rxjs/add/operator/toPromise';
@Injectable()
export class SmartTablesService {
smartTableData = this.http
.get('http://192.168.0.100:8000/json2')
.map(response => response.json())
.map(data =>
data.reduce((acc, item) => map.set(item.year, item.cost), new Map())
)
.zip(
this.http
.get('http://192.168.0.100:8000/json1')
.map(response => response.json()),
(lookup, data) =>
data.map(row => ({ ...row, cost: lookup.get(row.year) }))
);
constructor(private http: Http) {}
getData(): Promise<any> {
return this.smartTableData.toPromise();
}
}
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.