TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined

落花浮王杯 提交于 2019-12-11 00:58:41

问题


I get the following exception when a web service request fails.

TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined

Specifically the HTTP GET returns 400 Bad request.

Here you can find the involved component:

@Component({
    selector: 'events-list',
    directives: [EventRow],
    changeDetection: ChangeDetectionStrategy.OnPush,
    providers: [HTTP_PROVIDERS],
    template: `
<table>
    <tr *ngFor="let event of events | async" [event]="event" >
    </tr>
</table>
  `
})
export class EventsList implements OnInit {
    events: Observable<Event[]>;

    constructor(public http: Http) { }

    ngOnInit(): void {
        let obs;
        this.events = Observable
            .create((o) => {
                obs = o;
                obs.next();
            })
            .flatMap(() => {
                return this.http.get('event/view');
            })
            .retryWhen(error => {
                error.delay(3000);
            })
            .map((response: Response) => {
                setTimeout(() => {
                    obs.next();
                }, 10000);
                return (<any>response.json()).map(item => {
                    return item;
                });
            });
    }
}

Any suggestion?

Thanks in advance!


回答1:


I think that you missed a return in the retryWhen:

.retryWhen(error => {
  return error.delay(3000);
})


来源:https://stackoverflow.com/questions/37414855/typeerror-cannot-read-property-symbolsymbol-iterator-of-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!