I want to fetch data from a API. To fetch the data u need to pass the following conditions: U need to use a token. This token is only valid for a specific public IP. u need to use the bearer authentication scheme to fetch the data. Now i want to try this out. And started my application locally with the following code: `
public static USERTOKEN: string = '***';
constructor(private http: HttpClient) {
}
ngOnInit() {
const httpOptions = {
headers: new HttpHeaders({
'Authorization': ' Bearer ' + AppComponent.USERTOKEN
})
};
this.http.get('https://developer.clashofclans.com/clans/%2388GL8202', httpOptions).subscribe(data => {
console.log(data);
});
}
}
`
Of course i added the httpClientModule as a import in my module class. But i get the following error: Failed to load resource: the server responded with a status of 403 (Forbidden)
localhost/:1 Failed to load https://developer.clashofclans.com/clans/%2388GL8202: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 403.
What am I doing wrong? Is the bearer auhtorization wrong?