You should use one function for success execution and oanother function for failure.
Stuff.get({stuff:$routeParams.stuffId}, function(response, getReponseHeaders) {
// Here is success handler.
}, function(response, getReponseHeaders) {
// Here is failure handler.
if(response.status === 404) {
// Do something for error 404
}
}
On Friday, July 6, 2012 9:46:00 PM UTC+2, dylst wrote:
Hello!
I'm trying to handle non-200 status codes while using $resource, and I can't seem to get access to this data.
Stuff.get({stuff:$routeParams.stuffId}, function(response, getReponseHeaders) {
// on a 404, this block is never reached
}
I'm assuming I must be doing something wrong?
I checked the angular-resource source code, and I'm able to get the response code within the "then" block.
Before I dug into this unnecessarily, I thought I'd ask, as I'm assuming I'm making a simple mistake.
Any suggestions welcome. Thanks!