{"action":"closed","issue":{"url":"https://api.github.com/repos/adrianlee44/ng-backbone/issues/7","labels_url":"https://api.github.com/repos/adrianlee44/ng-backbone/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/adrianlee44/ng-backbone/issues/7/comments","events_url":"https://api.github.com/repos/adrianlee44/ng-backbone/issues/7/events","html_url":"https://github.com/adrianlee44/ng-backbone/issues/7","id":45786361,"number":7,"title":"HTTP response code not available in callback functions","user":{"login":"kvcrawford","id":504158,"avatar_url":"https://avatars.githubusercontent.com/u/504158?v=3","gravatar_id":"","url":"https://api.github.com/users/kvcrawford","html_url":"https://github.com/kvcrawford","followers_url":"https://api.github.com/users/kvcrawford/followers","following_url":"https://api.github.com/users/kvcrawford/following{/other_user}","gists_url":"https://api.github.com/users/kvcrawford/gists{/gist_id}","starred_url":"https://api.github.com/users/kvcrawford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kvcrawford/subscriptions","organizations_url":"https://api.github.com/users/kvcrawford/orgs","repos_url":"https://api.github.com/users/kvcrawford/repos","events_url":"https://api.github.com/users/kvcrawford/events{/privacy}","received_events_url":"https://api.github.com/users/kvcrawford/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/adrianlee44/ng-backbone/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-10-14T18:53:21Z","updated_at":"2015-01-21T06:02:07Z","closed_at":"2015-01-21T06:02:07Z","body":"For success and error callbacks, you get the following arguments: `(collection, response, options)`\r\n\r\nIn the normal Backbone + $.ajax world, [this callback function](https://github.com/jashkenas/backbone/blob/1.1.2/backbone.js#L863) gets passed to [$.ajax](http://api.jquery.com/jquery.ajax/), where the first argument is `data` (the data response from the server, parsed according to its dataType). Data then gets passed on to be the `response` argument of our callback.\r\n\r\nAt the same time, the jqXHR object returned by `$.ajax` gets assigned to `options.xhr`, so you are able to look at the response code from there. In contrast with current ng-backbone, `options.xhr` is just the promise returned by $http.\r\n\r\nTo make things more confusing, `$.ajax`'s error callback gets a `jqXHR` for its first argument...so while backbone's docs say that both callbacks get the same arguments `(collection, response, options)`, response is different for error...and you can grab the HTTP status code from it.\r\n\r\nWould you accept a PR that exposes the HTTP status code in some way? What if we did something like this...\r\n\r\n```js\r\nvar xhr = ajax(_.extend(params, options)).\r\n  success(function(data, status, headers, config) {\r\n    options.xhr = {\r\n      status: status\r\n      headers: headers\r\n      config: config\r\n    }\r\n\r\n    if (!isUndefined(options.success) && _.isFunction(options.success)) {\r\n      options.success(data);\r\n    }\r\n  }).\r\n  error(function(data, status, headers, config) {\r\n    options.xhr = {\r\n      status: status\r\n      headers: headers\r\n      config: config\r\n    }\r\n\r\n    if (!isUndefined(options.error) && _.isFunction(options.error)) {\r\n      options.error(data);\r\n    }\r\n  });\r\n```\r\n\r\noptions.xhr still wouldn't be an xhr object ($http doesn't give us that), but it would be a little bit closer. Currently options.xhr is just the same promise that already gets returned by the `fetch`, `create`, etc. functions."}}