I dont want to say you are doing it all wrong.. but you are def. abusing things. The default way to POST
something with ng-resource
is to use save. Second, the default way to send data is to instantiate a $resource
factory with the data you want. See _resource
below. We pass the data we want, and it will automagically convert it and if its a POST
send it in the body, or in the case of a GET
it will turn into query parameters.
UIAppResource.factory('User', function($resource) {
return {
changePassword: function(currentPass,
newPass,
confirmPass,
authtoken,
callback
) {
var Resq = $resource(baseURL + "modifyuser", {}, {
'save': {
method: 'POST',
headers: {
'Accept':'application/json',
'Content-Type':'application/json',
'X-Internal-Auth-Token': authtoken
}
}
});
var _resource = new Resq({
'currentPassword': currentPass,
'newPassword': newPass,
'confirmPassword': confirmPass
});
_resource.$save(callback);
}
};
});