0

The code below works in browser and on iPhone 5s but not in the iOS emulator. I'm trying to figure out if it's the emulator or something in ionic.

I have set the NSAppTransportSecurity in the Info.plist to be able to use http

NSAppTransportSecurity NSAllowsArbitraryLoads and the code:

accountRepo.register($scope.login.registryCode)
.success(function(data){
    accountRepo.user = data;
    $scope.hideLoading();
    $state.go("setPin");
})
.error(function(err){
    console.log(err);
    $scope.hideLoading();
    alert("Incorrect registry code");
});

and the repo

app.factory('accountRepo', function($http) {
   return {
     token: {},
     register: function(registryCode) {
       return $http.post("http://localhost:9501/register",
       {"registryCode": registryCode} );
     },

The err parameter is null when the error occurs. I get nothing in the output in Xcode. Should I look somewhere else?

1 Answer 1

1

A bit late, but someone might find this useful.

It's an issue of cross origin resource sharing (CORS), when doing ionic serve or ionic run -l.

You can solve that by setting a proxy in your ionic.project.

Check this article for more: http://blog.ionic.io/handling-cors-issues-in-ionic/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.