Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49169

Rest API call from Ionic app

$
0
0

@srispkrishnan wrote:

Hi,

I am new to Ionic. I just started developing my 1st app.

I am just making a rest call just to display city list. Intially I have faced CORS problem and I have rsolved it by refering to http://blog.ionic.io/handling-cors-issues-in-ionic/

I have added the proxy block as mentioned below to my ionic.project file.
"proxies": [
{
"path": "/renu/api/GetStations/RBKAL/RBKAL",
"proxyUrl": "http://124.146.119.122/renu/api/GetStations/RBKAL/RBKAL"
}
]

Below is my controller code where I am making rest call
$http({
method : "GET",
//url : "http://localhost:8100/renu/api/GetStations/RBKAL/RBKAL"
url: "file://renu/api/GetStations/RBKAL/RBKAL"
}).then(function mySucces(response) {
$scope.selectables = response.data.stationDetails
}, function myError(response) {

});

It works fine with url: "http://localhost:8100/renu/api/GetStations/RBKAL/RBKAL while running throught ionic serve. But when I change the url to file://renu/api/GetStations/RBKAL/RBKAL to genereate apk file to deploye it under andriod device as suggested in http://blog.ionic.io/handling-cors-issues-in-ionic/. It's not working. So if anyone knows how to reframe the URL while generting the apk file, guide me to solve this issue.

Regards,
Navaneeth

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49169

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>