Error handling in ngResource action

Is it possible to stop the call transformResponsein action ngResource from the called failed response. For example, a user resource will search data.user.firstnamein the response here, even if the request fails and the response data does not have the 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 transformResponse, but this seems like a hack more than the angular command expected.

+3
source share

All Articles