how to implement api proxy in ionic? My console.log says
“Failed to load https://api.wh.geniussports.com/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782&fromDate=2017-11-17&toDate=2017-12-17&teamId=88261&limit=1: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8100’ is therefore not allowed access.”
Someone said I’m gonna use proxy api.
my actual api:
https://api.wh.geniussports.com/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782&fromDate=2017-11-17&toDate=2017-12-17&teamId=88261&limit=1
my ionic.config.json
{
"name": "slingers",
"app_id": "",
"type": "ionic-angular",
"integrations": {
"cordova": {}
},
"proxies": [
{
"path": "/api",
"proxyUrl": "https://api.wh.geniussports.com"
}
]
}
my home.ts
getMatches(){
this.http.get(this.lets + '/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782&fromDate=2017-11-17&toDate=2017-12-17&teamId=88261&limit=1')
.map(res => res.json())
.subscribe(data => {
this.dataMatches = data.response.data;
console.log(this.dataMatches);
}, err => {
console.log(err);
});
}
in my ios device console says:
http://localhost:8080/api/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782&fromDate=2017-11-17&toDate=2017-12-17&teamId=88261&limit=1
Failed to load resource: the server responded with a status of 404 (Not Found)