Hi guys,
I'm using $resource for downloading the data from the server. Using $resources looks like the most elegant solution for REST API's but I'm facing a problem reading HTTP status when downloading wasn't successful, status is always equal to 0.
Examples are in coffescript
resource = $resource server.entitiesURL,
{resource:'', callback:'JSON_CALLBACK'},
{query:method:'JSONP', isArray:true}
resource.query {resource:key},
((response) =>
#OK
),
((response) =>
console.log response.status
)
Error handler always output response.status 0.
The same happens when I'm using HTTP interceptors, it never gets to 404 since the status is always 0
interceptor = ["$rootScope", "$q", (scope, $q) ->
success = (response) ->
return response
error = (response) ->
status = response.status
switch status
when 404
#do stuff
$q.reject response
else
$q.reject response
(promise) ->
promise.then success, error
]
$httpProvider.responseInterceptors.push interceptor
Any ideas how to read "a real" status from the response?
Thanks!