我想在下面解决这个错误 . 运行应用程序不是问题,但是一旦我运行'npm start',我看到编译失败,因为下面的错误 .
'Match []'类型中不存在属性'匹配'
这是来自外部api的http.get函数
getdata(id: string): Observable<Match[]>
{
this.setURL(id);
return this.http.get<Match[]>(this.apiurl, httpOptions).pipe(map((res) => res));
}
这是接收响应的功能
private history: Match[];
getHistory(id: string): void {
this.summonerHistoryService.getdata(id)
.subscribe((his) => {
//console.log(his);
this.history = his.matches;
这是一个名为“匹配”的界面
export interface Match{
lane: string;
gameId: number;
champion: number;
platformId: string;
timestamp: number;
queue: number;
role: string;
season: number;
}
get的响应格式是
endIndex:5
matches:(5) [{…}, {…}, {…}, {…}, {…}]
startIndex:0
totalGames:144
所以我所做的只是从响应中获得“匹配”并将其保存到历史记录中 . 但是,我一直收到错误 . 不知道如何检索作为响应一部分的数组 .