【发布时间】:2018-06-13 20:07:30
【问题描述】:
我有一个 Angular 5 应用程序,组件中有以下代码:
ngOnInit() {
Observable.forkJoin([
this.highlightedInsight = this.insightService.getHighlightedInsight(),
this.insights = this.insightService.getInsightsList(),
this.topics = this.insightService.getInsightTopicsList()
]).subscribe(
response => {},
error => {
console.log('An error occurred:', error);
},
() => {
this.loading = false;
});
}
我的html:
<div class="internal-wrapper" *ngIf="!loading">
<app-highlighted-insight [insight]="highlightedInsight | async"></app-highlighted-insight>
<app-topic-filter [topics]="topics | async"></app-topic-filter>
<app-insight-list [insights]="insights | async"></app-insight-list>
</div>
在我的 Chrome 网络标签中,3 个 API 调用中的每一个都运行了两次。我做错了什么?
【问题讨论】:
-
可能是预检请求。如果你在第一个请求中看到这个
Request Method:OPTIONS,那就没问题了。 -
谢谢,我已经检查过了。 :-) 这不是预检
标签: javascript angular observable