I'm sending a request to an external api and the above error is displayed
Here's my Ts
import { Component, OnInit } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
@Component({
selector: 'app-standings',
templateUrl: './standings.component.html',
styleUrls: ['./standings.component.css']
})
export class StandingsComponent implements OnInit {
headers = new HttpHeaders();
url1: any;
constructor(private http: HttpClient) {
this.headers.append('X-RapidAPI-Key', 'myKey');
this.url1 = 'https://api.football-data.org/v2/competitions/SA/scorers';
}
getStandings() {
return this.http.get(this.url1,{headers: this.headers})
.subscribe(response => console.log(response))
}
ngOnInit(): void {
this.getStandings()
}
}
I've tried to add 'Access-Control-Allow-Origin': '*' to the Httpheaders constructor but i also get errors ,
I've also tried to create a proxy configuration file and added it into angular.json but still the error existed
Help please !