我是Angular 6.X和rxjs的新手。我正在尝试实现可观察的点击操作。它通过RestApi提取数据,但是在data ['list']。map的异常之下,我尝试了不同的方法,但没有一个解决。
get(): Observable<ProgramOwnerVulnerability[]> {
//explicitly do not type this get, due to list structure returned
return this.http
.get(this.programListUrl)
.pipe(map((data) => {
//map data appropriately into the correct type
return data['list'].map((programOwnerVulnerabilityJson) => {
return new ProgramOwnerVulnerability(programOwnerVulnerabilityJson);
});
}));
}
例外:
core.js:1598 ERROR TypeError: Cannot read property 'map' of undefined
at MapSubscriber.project (program-owner.service.ts:29)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:75)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:93)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:81)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:93)
at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/operators/filter.js.FilterSubscriber._next (filter.js:85)
at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:93)
at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber.notifyNext (mergeMap.js:136)
at InnerSubscriber.push../node_modules/rxjs/_esm5/internal/InnerSubscriber.js.InnerSubscriber._next (InnerSubscriber.js:20)
at InnerSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:93)