Reputation: 1
My code fetches the apigee collection fine when running on the desktop with Chrome browser.
When I turn it into an app via phonegap/android-studio and run it on my android phone it shows my alert: "error fetching remote candidate data" that means fetch returned an error.
Why would this fetch the collection on the desktop but not the phone? (guest has GET permissions for the collection)
function loadRemoteData() {
endorseds = new Apigee.Collection({
"client": client,
"type": "endorseds",
"qs": {
"limit": 4000,
"ql": "order by order,district,name"
}
});
$.mobile.loading("show");
endorseds.fetch(function(err, data) {
if (err) { alert("error fetching remote candidate data ");
if(lastLocalDate > 0){
loadLocalData();
}
$.mobile.loading("hide");
} else {
alert("remote fetch ok");
localStorage.setItem('endorseds', endorseds.serialize());
if(lastRemoteDate == 0) lastRemoteDate = getToday();
localStorage.setItem('lastdate',lastRemoteDate);
$.mobile.loading("hide");
showMain();
}
});
}
Upvotes: 0
Views: 67
Reputation: 21
The answer depends upon the version of PhoneGap that you are using. Have a look at the config.xml file. At the bottom (by default) of the file, you should see a line where "something here" was 127.0.0.1/* in older versions of PhoneGap. I'm not sure where it got change (3.2, I believe), but it is now which allows the app to communicate with any web site/application. Change that line to the wildcard and recompile – this should solve the issue.
Upvotes: 2