Is there any way to stop a transformResponse
on an ngResource action from being called on a failed response. For example, the user resource here will look for data.user.firstname
in the response even if the request fails and the response data doesn't have a user in it.
$resource("user", null, {
login: {
method: "POST",
transformResponse: function(data) {
return {
given: data.user.firstname,
family: data.user.lastname,
email: data.user.email,
type: data.user.type
};
}
}
});
I can put some conditional logic in the transformResponse, but that seems like a hack more than what the angular team intended.