Hi,

Should your server return with anything after getting the post message?

If so, try this:

Restangular.all('post').post($scope.userPost).then(function(result){

    $scope.people = result.plain;

});


Snippet from their site (https://github.com/mgonto/restangular) :

// POST /accounts/123/buildings with MyBuilding information
  firstAccount.post("Buildings", myBuilding).then(function() {
    console.log("Object saved OK");
  }, function() {
    console.log("There was an error saving");
  });


- -
--  Csanyi Andras (Sayusi Ando)  -- http://sayusi.hu --
http://facebook.com/andras.csanyi
--  ""Trust in God and keep your gunpowder dry!" - Cromwell

On 6 May 2016 at 22:24, Jaime Gomez <[email protected]> wrote:

>
>
> down votefavorite
> <http://stackoverflow.com/questions/37080509/send-by-post-with-restangular#>
>
> I'm trying to send a json by post with restangular but this don't return
> me anything.
>
> Code:
>
> $scope.userPost = {
>
>         title: 'foo',
>         body: 'bar',
>         userId: 1
>     }
>
>     $scope.registerUser=function(){
>         $scope.people = Restangular.all('post').post($scope.userPost);
>         console.log($scope.people);
>     }
>
> Usually I use like this with ajax, it return me a json:
>
> $.ajax('http://jsonplaceholder.typicode.com/posts', {
>   method: 'POST',
>   data: {
>     title: 'foo',
>     body: 'bar',
>     userId: 1
>   }}).then(function(data) {
>   console.log(data);});
>
> Any ideas ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to