Using ngResource in AngularJS 1.2rc(x), how do I get the status code now?
RestAPI.save({resource}, {data}, function( response, responseHeaders ) {
});
where RestAPI is my ngResource.
The response has the $promise object and the resource returned from the server but not a status anymore. The responseHeaders() function only has a status if the server injects the status code into the header object, but not the true returned status code. So some servers may serve it and some might not.
I agreed
responseHeaders()function will only return response's header,but you can custom it and it's useful anyway.1.
To solve you problem. With the following:(
$$serviceis my $resource instance.)In this way,u can only catch
status,statusText,timeout,method,headers(same with responseHeaders)in ERROR response.2.
If you want to see response details in success response,I used a interceptor like this:
and then add interceptor to module: