{"action":"created","issue":{"url":"https://api.github.com/repos/bitinn/node-fetch/issues/8","labels_url":"https://api.github.com/repos/bitinn/node-fetch/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/bitinn/node-fetch/issues/8/comments","events_url":"https://api.github.com/repos/bitinn/node-fetch/issues/8/events","html_url":"https://github.com/bitinn/node-fetch/issues/8","id":63172641,"number":8,"title":"tasks for considering (2.0 release)","user":{"login":"bitinn","id":1484279,"avatar_url":"https://avatars.githubusercontent.com/u/1484279?v=3","gravatar_id":"","url":"https://api.github.com/users/bitinn","html_url":"https://github.com/bitinn","followers_url":"https://api.github.com/users/bitinn/followers","following_url":"https://api.github.com/users/bitinn/following{/other_user}","gists_url":"https://api.github.com/users/bitinn/gists{/gist_id}","starred_url":"https://api.github.com/users/bitinn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitinn/subscriptions","organizations_url":"https://api.github.com/users/bitinn/orgs","repos_url":"https://api.github.com/users/bitinn/repos","events_url":"https://api.github.com/users/bitinn/events{/privacy}","received_events_url":"https://api.github.com/users/bitinn/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bitinn/node-fetch/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-03-20T06:23:41Z","updated_at":"2015-11-18T07:21:09Z","closed_at":null,"body":"just collecting some common complain about 1.x release\r\n\r\n- [ ] provide some guideline on how to handle rejected promise (failed fetch), this can be caused by many reasons: url, headers.location, network timeout, request config etc; currently the only way to distinguish them is to check error message.\r\n\r\n- [ ] provide some alternatives to extract redirect headers, it's not possible with current fetch spec, only the final url will be expose to user when following redirects.\r\n\r\n- [ ] some way for cookies to persist when you do a POST request that redirects (which should be followed by a GET request, often with cookie as credential). Though if we implement extraction for redirect headers we can make this possible (keep the cookie headers for your next GET request).\r\n\r\n- [x] expose Request/Headers/Response interfaces, we don't currently have a Request interface due to the fact that no one are using them.\r\n\r\n- [x] normalize Headers `.set` and `.append` to prevent non-string input, it's recommended to already cast your input to `String` type first.\r\n"},"comment":{"url":"https://api.github.com/repos/bitinn/node-fetch/issues/comments/157630108","html_url":"https://github.com/bitinn/node-fetch/issues/8#issuecomment-157630108","issue_url":"https://api.github.com/repos/bitinn/node-fetch/issues/8","id":157630108,"user":{"login":"aarongreenwald","id":6300588,"avatar_url":"https://avatars.githubusercontent.com/u/6300588?v=3","gravatar_id":"","url":"https://api.github.com/users/aarongreenwald","html_url":"https://github.com/aarongreenwald","followers_url":"https://api.github.com/users/aarongreenwald/followers","following_url":"https://api.github.com/users/aarongreenwald/following{/other_user}","gists_url":"https://api.github.com/users/aarongreenwald/gists{/gist_id}","starred_url":"https://api.github.com/users/aarongreenwald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aarongreenwald/subscriptions","organizations_url":"https://api.github.com/users/aarongreenwald/orgs","repos_url":"https://api.github.com/users/aarongreenwald/repos","events_url":"https://api.github.com/users/aarongreenwald/events{/privacy}","received_events_url":"https://api.github.com/users/aarongreenwald/received_events","type":"User","site_admin":false},"created_at":"2015-11-18T07:21:09Z","updated_at":"2015-11-18T07:21:09Z","body":"@bitinn It's not hitting the `.then`, it's going straight to `.catch`. To be honest I don't fully understand how `nock` is returning the data, but `request` is grabbing the response and passing it to the callback as an object in the `error` argument.\r\n\r\nThe following is from the `nock` tests. Notice how the test gets the supplied object in `req.on('error'...`. `node-fetch` is throwing a new error in `req.on('error'...`\r\n\r\n```\r\ntest(\"replyWithError allows json response\", function(t) {\r\n    var scope = nock('http://www.google.com')\r\n        .post('/echo')\r\n        .replyWithError({message: \"Service not found\", code: 'test'});\r\n\r\n    var req = http.request({\r\n        host: \"www.google.com\"\r\n        , method: 'POST'\r\n        , path: '/echo'\r\n        , port: 80\r\n    });\r\n\r\n    // An error should have have been raised\r\n    req.on('error', function(e) {\r\n      scope.done();\r\n      t.equal(e.message, 'Service not found');\r\n      t.equal(e.code, 'test');\r\n      t.end();\r\n    });\r\n\r\n    req.end();\r\n});\r\n\r\n```"}}