{"action":"created","issue":{"url":"https://api.github.com/repos/github/fetch/issues/312","repository_url":"https://api.github.com/repos/github/fetch","labels_url":"https://api.github.com/repos/github/fetch/issues/312/labels{/name}","comments_url":"https://api.github.com/repos/github/fetch/issues/312/comments","events_url":"https://api.github.com/repos/github/fetch/issues/312/events","html_url":"https://github.com/github/fetch/issues/312","id":147464357,"number":312,"title":"IE throws errors for 401 status codes via CORS","user":{"login":"andykent","id":614,"avatar_url":"https://avatars.githubusercontent.com/u/614?v=3","gravatar_id":"","url":"https://api.github.com/users/andykent","html_url":"https://github.com/andykent","followers_url":"https://api.github.com/users/andykent/followers","following_url":"https://api.github.com/users/andykent/following{/other_user}","gists_url":"https://api.github.com/users/andykent/gists{/gist_id}","starred_url":"https://api.github.com/users/andykent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andykent/subscriptions","organizations_url":"https://api.github.com/users/andykent/orgs","repos_url":"https://api.github.com/users/andykent/repos","events_url":"https://api.github.com/users/andykent/events{/privacy}","received_events_url":"https://api.github.com/users/andykent/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2016-04-11T15:27:13Z","updated_at":"2016-04-12T14:17:29Z","closed_at":"2016-04-11T16:28:07Z","body":"Not sure if this is fixable or expected but I couldn't find it documented anywhere. \r\n\r\nusecase: We are calling an API that can return 401 status codes and so need to ask you to login when this happens.\r\n\r\nA minimal reproduction would look something like this...\r\n\r\n```javascript\r\nfetch(SOME_URL_THAT_RETURNS_401)\r\n  .then(function(r) { console.log('success', r.status) })\r\n  .catch(function(e) { console.log('error ', e) })\r\n```\r\n\r\nIn Chrome/FF this logs `success 401` but in IE10 this logs `error TypeError: Network request failed` \r\n\r\nThe docs state...\r\n\r\n> The Promise returned from fetch() won't reject on HTTP error status even if the response is a HTTP 404 or 500. Instead, it will resolve normally, and it will only reject on network failure, or if anything prevented the request from completing.\r\n\r\nSo I'm guessing this is a difference of IE treating 401 as an error condition but I feel like it should be normalised in the polyfill or at least documented somewhere if it's not possible to fix. \r\n"},"comment":{"url":"https://api.github.com/repos/github/fetch/issues/comments/208928540","html_url":"https://github.com/github/fetch/issues/312#issuecomment-208928540","issue_url":"https://api.github.com/repos/github/fetch/issues/312","id":208928540,"user":{"login":"andykent","id":614,"avatar_url":"https://avatars.githubusercontent.com/u/614?v=3","gravatar_id":"","url":"https://api.github.com/users/andykent","html_url":"https://github.com/andykent","followers_url":"https://api.github.com/users/andykent/followers","following_url":"https://api.github.com/users/andykent/following{/other_user}","gists_url":"https://api.github.com/users/andykent/gists{/gist_id}","starred_url":"https://api.github.com/users/andykent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andykent/subscriptions","organizations_url":"https://api.github.com/users/andykent/orgs","repos_url":"https://api.github.com/users/andykent/repos","events_url":"https://api.github.com/users/andykent/events{/privacy}","received_events_url":"https://api.github.com/users/andykent/received_events","type":"User","site_admin":false},"created_at":"2016-04-12T14:17:29Z","updated_at":"2016-04-12T14:17:29Z","body":"Yep, for sure, that's the conclusion I am coming to as well.\r\n\r\nI think this bit of the readme is somewhat misleading given the IE situation...\r\n\r\n> The Promise returned from fetch() won't reject on HTTP error status even if the response is a HTTP 404 or 500. Instead, it will resolve normally, and it will only reject on network failure, or if anything prevented the request from completing.\r\n\r\nmaybe that wording should be adjusted? it's sort of a Caveat to the Caveat :)\r\n\r\nAnyway, I'm off to cry into my keyboard and I start returning 200 responses with an unauthorised JSON payload. :( \r\n\r\nThanks a bunch for hearing me out anyway."}}