0

I have an error when trying to post data to parse... for hours now, am not able to get this right...

I have search stackoverflow to see if i can get solution but the errors still persist...

enter image description here

here is my code

   controller('CreateAccountCtrl', function($scope, $state, $http){
    $scope.user ={
        email:'',
        phone:'',
        password:'',
        username:'',
        name:''
    }
    $scope.doSignUp = function(){
        console.log("doing sign up");
        var headers = new Headers();
        headers.append('x-parse-application-id', 'AppId1');
        headers.append('x-parse-rest-api-key', 'restAPIKey');
        headers.append('Content-Type','application/json')

        var dataObject = {
            "first_name": $scope.name,
            "username": $scope.last_name,
            "passsword": $scope.passsword,
            "email": $scope.email
        };
        var dataObjectString = JSON.stringify(dataObject);
        var baseURL  ="https://outing-zionnite.c9users.io/app1/classes/user";
        $http.post(baseURL, dataObjectString, {headers: headers})
        .then(function (response) {
            console.log('adding to parse', response);
            return response.data;
        });

        //$state.go('app.feed');


        //$state.go('app.feed');
    };
})
rici
  • 234,347
  • 28
  • 237
  • 341
user3728868
  • 75
  • 1
  • 9

1 Answers1

0

Okay i was able to fix it up like this... but yet i can really tell the difference between this code and the previous one

.controller('CreateAccountCtrl', function($scope, $state, $http,  $ionicHistory){
    $ionicHistory.clearCache();
    $scope.user ={
        email:'',
        phone:'',
        password:'',
        userName:'',
        name:''
    }
 $scope.doSignUp = function(){
        console.log($scope.user.name);
        console.log($scope.user.userName);
        var dataObject = {
            "name": $scope.user.name,
            "img_url": $scope.user.name,
            "phone": $scope.user.phone,
            "username": $scope.user.userName,
            "password": $scope.user.phone,

        };
        var dataObjectString = JSON.stringify(dataObject);
        var baseURL  ="https://outing-zionnite.c9users.io/app1/classes/_User";

        console.log(baseURL);
        $http({
          url: baseURL,
          method: "POST",
          data: dataObjectString,
          headers: {'Content-Type': 'application/json',
                    'x-parse-application-id': 'AppId1',
                    'x-parse-rest-api-key':'restAPIKey'
                   }
      }).success(function (res) {
              $scope.persons = res; // assign  $scope.persons here as promise is resolved here
              console.log("Entered    "+res);
          }).error(function (res) {
              $scope.status = status;
          });
 //$state.go('app.feed');


 //$state.go('app.feed');
 };
})
user3728868
  • 75
  • 1
  • 9