我有一个api,返回像这样的对象/数组:
(2) [{...},{...}] object 0: {a: '1',b: {id: '1'}} 1: {a: '2',b: {id: '2'}}
所以它看起来像对象的数组(但是debuges说’对象’).
所以在我的代码中我有:
return this.http.get(this.url).pipe( map(datas => { return datas.map(data => { let object = { a: data['a'],b: data['b']['id'],} return object; }) }) );
但那里:
return datas.map(data => {
我收到一个错误:
Property 'map' does not exist on type 'Object'.
我能做什么?
解决方法
以下运算符在RXJS6中重命名
catch() => catchError() do() => tap() finally() => finalize() switch() => switchAll()
throw() => throwError() fromPromise() => from() (this automatically detects the type)
FOR MAP语法
import { map } from 'rxjs/operators'; myObservable .pipe(map(data => data * 2)) .subscribe(...);