问题
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