typescript - RXJS and Angular: Take a number of elements in an array -
i'm trying wrap head around rxjs.
i'm getting array of things via http request.
but i'm having trouble taking number of objects.
here's method.
getthingsbyid(id: number): observable<ithing[]> { return this._http.get(this.url + id + '/things) .map((response: response) => <ithing[]>response.json()) .take(20); }
when try take 20 of things of them.
what doing wrong?
thanks!
try array.slice()
method:
getthingsbyid(id: number): observable<ithing[]> { return this._http.get(`${this.url}${id}/things`) .map((response: response) => <ithing[]>response.json().slice(0, 20)); }
Comments
Post a Comment