我正在使用rapidapi从足球应用程序获取一些数据,但可以理解为什么会抛出此错误。
我已经尝试过这段代码,但它不起作用,这显示了这种类型的错误
Response { type: "cors", url: "https://soccer-livescore.p.rapidapi.com/v1/global/getleague?league=Indo%20D3", redirected: false, status: 403, ok: false, statusText: "Forbidden", headers: Headers, body: ReadableStream, bodyUsed: false }
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-matches',
templateUrl: './matches.page.html',
styleUrls: ['./matches.page.scss'],
})
export class MatchesPage implements OnInit {
constructor(public http: HttpClient){}
ngOnInit() {
fetch("https://soccer-livescore.p.rapidapi.com/v1/global/getleague?league=Indo%20D3", {
"method": "GET",
"headers": {
"x-rapidapi-host": "soccer-livescore.p.rapidapi.com",
"x-rapidapi-key": "not showing my rapid key"
}
})
.then(response => {
console.log(response);
})
.catch(err => {
console.log(err);
});
}
}