node.js - Angularjs passing variables from controller to dao service -


i trying pass variable controller dao service in angularjs application (frontend) , nodejs backend.

here controller :

    $scope.afficherprofils = function() {     $http.get(configuration.url_request + '/profile')         .success(function(data) {             $scope.owner = data._id;             console.log('$scope.owner =========>');             console.log($scope.owner);             $http.get(configuration.url_request + '/listerprofil', {                 owner: $scope.owner             })                 .success(function(data) {                     console.log('$scope.listeprofils =========>');                     console.log(data);                     $scope.listeprofils = data;                 });         }); }; 

i calling /profile _id of account has added profile, after call /listerprofil inside success , pass owner parameter.

and in dao service code following :

 exports.all = function(req, res) {   console.log('req.body ================================>');   console.log(req.body);   profil.find({     owner: req.body.owner   }, function(err, profils) {     if (err) {       res.send({         'result': 'error'       });     } else {       res.send(profils);     }   }); }; 

and don't know why req.body empty when console.log

any ideas ?

http-crud(create-$http.post,read-$http.get,update-$http.put,dlete-$http.delet)

$http.get-it used value means body contain empty value  $http.post-it used create value means body contain data (your post data server)  $http.update-it used update exit value body contain data  $http.delete-it used delete exit value body contain empty(send through param(?id=1111)) 

so change code http.get http.post


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -