Angularjs does not post JSON data to REST API -


i new angularjs. trying post data local server. below code.

        var postobject = new object();         postobject.email = "emailtobesaved1";         postobject.userdata ="userdatatobesaved";         var s=json.stringify(postobject);          $http({             url: 'http://localhost:8080/people',             datatype: 'json',             method: 'post',             data: s,             headers: {                 "content-type": "application/json"             }         }).success(function(response){             $scope.response = response;         }).error(function(error){             $scope.error = error;         }); 

this data not posted. missing something? activated proper cors filter in server side. server side spring boot application.

thanks in advance.

you should not convert data object string , send it. send json object itself

try code instead:

var postobject = new object();     postobject.email = "emailtobesaved1";     postobject.userdata ="userdatatobesaved";     //var s=json.stringify(postobject);      $http({         url: 'http://localhost:8080/people',         datatype: 'json',         method: 'post',         data: postobject,         headers: {             "content-type": "application/json"         }     }).success(function(response){         $scope.response = response;     }).error(function(error){         $scope.error = error;     }); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -