1
catch
から値を返そうとすると、以下のエラーが発生します。私は根本的に間違ったことをやっています。私に手がかりを与えてください。をcatch
から返せないのはなぜですか?エラー:未知(約束):TypeError:未定義のプロパティ 'map'を読み取ることができません
.TS
getMyTopic() {
return this.topicSer.getMyTopics().map((res: any) => res.json()).map((res: any) => res = res.categories)
.catch((err: any) => {
console.log('err', err);
return []
})
}
provider.ts
getMyTopics(): Observable<any> {
if (typeof this.userService.userDetails != 'undefined') {
this.localCacheService.getItem(this.localCacheService.discoverTopicsKey).then((val) => {
if (val != null && val.length == 0) return this.apiService.get(config.discover_topic_WITHAUTH);
}).catch(() => {
return this.apiService.get(config.discover_topic_WITHOUTAUTH);//here is the issue
});
}
エラー
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'map' of undefined
TypeError: Cannot read property 'map' of undefined
at Discover.webpackJsonp.402.Discover.getMyTopic (discover.ts:123)
at Discover.webpackJsonp.402.Discover.getData (discover.ts:69)
at discover.ts:51
at t.invoke (polyfills.js:3)
at Object.onInvoke (core.js:4626)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.js:4617)
at Discover.webpackJsonp.402.Discover.getMyTopic (discover.ts:123)
at Discover.webpackJsonp.402.Discover.getData (discover.ts:69)
at discover.ts:51
at t.invoke (polyfills.js:3)
at Object.onInvoke (core.js:4626)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.js:4617)
at c (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.js:4617)
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)
at o (polyfills.js:3)
at e.invokeTask [as invoke] (polyfills.js:3)
at p (polyfills.js:2)
at IDBRequest.v (polyfills.js:2)
defaultErrorLogger @ core.js:1350
ErrorHandler.handleError @ core.js:1411
IonicErrorHandler.handleError @ ionic-error-handler.js:61
next @ core.js:5373
schedulerFn @ core.js:4220
SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
SafeSubscriber.next @ Subscriber.js:185
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.js:4200
(anonymous) @ core.js:4648
t.invoke @ polyfills.js:3
r.run @ polyfills.js:3
NgZone.runOutsideAngular @ core.js:4574
onHandleError @ core.js:4648
t.handleError @ polyfills.js:3
r.runGuarded @ polyfills.js:3
(anonymous) @ polyfills.js:3
n.microtaskDrainDone @ polyfills.js:3
o @ polyfills.js:3
e.invokeTask @ polyfills.js:3
p @ polyfills.js:2
v @ polyfills.js:2
IndexedDB (async)
(anonymous) @ localforage.js:826
t.invoke @ polyfills.js:3
onInvoke @ core.js:4626
t.invoke @ polyfills.js:3
r.run @ polyfills.js:3
(anonymous) @ polyfills.js:3
t.invokeTask @ polyfills.js:3
onInvokeTask @ core.js:4617
t.invokeTask @ polyfills.js:3
r.runTask @ polyfills.js:3
o @ polyfills.js:3
e.invokeTask @ polyfills.js:3
p @ polyfills.js:2
v @ polyfills.js:2