Search code examples
javascriptangularjsangular-resource

simple Angular POST request with resource


I need to send a simple post request with resource in Angular v-1. this request must has a body like bottom:

{name: "mike", code: "1234"}

$scope.pmbusInfo = $resource('http://there.com:8080/api/v1/user/detail',
  null,
  {get: {method: 'POST'}}
);

console.log($scope.pmbusInfo.get({}, {name: "mike", code: "1234"}));

but the top codes, can't send body.

what's the problem?

Update

what is save function, is it a built-in function for resource ???

Update

The first adderss was wrong and i modify that now, there was an special port that i have to request to it.


Solution

  • The url in resource requests can contain parameters. we can set parameters with : in url. At the other side, the port separated in the url via a : and angular think that is a parameters and clear it when wanna to send request.

    so port must write in url like http://there.com\\:8080/api/v1/user/detail.