Issue
i was trying to use an remote api in my ionic app..but its showing following error
XMLHttpRequest cannot load http://localhost:54276/api/products?key1=value1&key2=value2. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.
am running on chrome
using ionic serve
...
i read some articles on ionic blog regarding CROS but i didn't get it well.can any one help me to fix it here is mycontroller
code
$scope.getData = function() {
$http.get("http://localhost:54276/api/products", { params: { "key1": "value1", "key2": "value2" } })
.success(function(data) {
$scope.username = data.username;
$scope.password = data.password;
})
.error(function(data) {
alert("Sorry");
});
}
Solution
thanks every one..just made it by adding
"proxies": [{
"path": "/api",
"proxyUrl": "//your url"
}]
to ionic.config
Answered By - Edison
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.