I am trying to connect to an Api (who is not mine), but i get CORS error (screen 1).
Then i tried to add 'Access-Control-Allow-Origin': '*' in my header but i get the same result (screen2).
Here is my code :
import { Component, OnInit } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
@Component({
selector: 'app-analyzer',
templateUrl: './analyzer.component.html',
styleUrls: ['./analyzer.component.scss']
})
export class AnalyzerComponent implements OnInit {
constructor(private http: HttpClient) {
this.getDeck().subscribe(res => console.log(res));
}
ngOnInit() {
}
getDeck() {
const headers = new HttpHeaders({
'Access-Control-Allow-Origin': '*'
});
return this.http.get('https://www.keyforgegame.com/api/decks/30763530-041c-4e15-b506-3456e79141d2/',
{headers: headers}
);
}
}
I don't know what to do anymore..
Thanks