无法获取未定义或空引用的属性"0" [英] Unable to get property '0' of undefined or null reference
问题描述
我收到以下错误,该错误仅在IE/Edge中显示.
I am getting the following error which shows up in IE/Edge only.
Unable to get propety '0' of undefined or null reference
我通过以下方式使用RxJ的可观察对象:
I am using RxJs observables in the following manner:
getVersions(): void {
this.databaseService.getProductVersions().subscribe(
(versions) => this.processVersions(versions),
(error) => console.error(error)
);
}
,并且在Chrome/Firefox中可以正常运行. productVersions看起来像这样:
and in Chrome/Firefox this works without errors. productVersions looks like this:
getProductVersions(): Observable<any[]> {
let options = this.header();
let url: string = this.baseUrl + 'admin/version/searchall';
return this.http.get(url, options).map(
response => response.json(),
error => console.log(error)
);
}
我不正确地使用Observable吗?我应该取消订阅吗? (我的api调用是有限的,因此从我阅读的内容中取消订阅是没有必要的.)
Am I using the Observable incorrectly. Should I be unsubscribing? (My api call is finite so from what I've read unsubscribing is not necessary).
推荐答案
我认为我已经排除了我正在使用的第3方库.但是我发现它正在那里发生.因此,不是我的代码导致了此问题.感谢@Martin和@Jakub的帮助.多亏了您,我至少现在正确地使用了map/catch方法.
I thought I had ruled out the 3rd party library I was using. But I found that it was happening there. So it was not my code causing the issue. Thanks @Martin and @Jakub for your help. I am at least now using the map/catch methods correctly thanks to you.
这篇关于无法获取未定义或空引用的属性"0"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!