XMLHttpRequest cannot load http://panel.dnsitexperts.com/AppWebService.asmx/Getdata?ACTION=getdata. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8100’ is therefore not allowed access.
I’m facing this error when I implement service for get Data
You have to use a proxy in your ionic.cofig file.
Or you can use this: https://crossorigin.me
how can I use proxy in ionic.config file
Like this
{
"name": "helloworld",
"app_id": "123456",
"v2": true,
"typescript": true,
"proxies": [
{
"path": "/api",
"proxyUrl": "https://owapi.net/api/v3"
}
]
}
And then you can use it like this http.get('/api/')
1 Like
what is in proxyUrl and in path also…means what I have to set
The path is the string you have to use in your http service.
So when you name the path ‘api’ you have to call your API like that
getAbility() {
return this.http.get('/api' + '/ability')
.map(res => res.json())
.do(resData => console.log(resData))
.toPromise();
}
The proxyUrl is the endpoint of you API.
1 Like