{"action":"created","issue":{"url":"https://api.github.com/repos/basti1302/traverson/issues/28","labels_url":"https://api.github.com/repos/basti1302/traverson/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/basti1302/traverson/issues/28/comments","events_url":"https://api.github.com/repos/basti1302/traverson/issues/28/events","html_url":"https://github.com/basti1302/traverson/issues/28","id":55013461,"number":28,"title":"not handling errors in request.js","user":{"login":"luigibozzo","id":97292,"avatar_url":"https://avatars.githubusercontent.com/u/97292?v=3","gravatar_id":"","url":"https://api.github.com/users/luigibozzo","html_url":"https://github.com/luigibozzo","followers_url":"https://api.github.com/users/luigibozzo/followers","following_url":"https://api.github.com/users/luigibozzo/following{/other_user}","gists_url":"https://api.github.com/users/luigibozzo/gists{/gist_id}","starred_url":"https://api.github.com/users/luigibozzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luigibozzo/subscriptions","organizations_url":"https://api.github.com/users/luigibozzo/orgs","repos_url":"https://api.github.com/users/luigibozzo/repos","events_url":"https://api.github.com/users/luigibozzo/events{/privacy}","received_events_url":"https://api.github.com/users/luigibozzo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"basti1302","id":73801,"avatar_url":"https://avatars.githubusercontent.com/u/73801?v=3","gravatar_id":"","url":"https://api.github.com/users/basti1302","html_url":"https://github.com/basti1302","followers_url":"https://api.github.com/users/basti1302/followers","following_url":"https://api.github.com/users/basti1302/following{/other_user}","gists_url":"https://api.github.com/users/basti1302/gists{/gist_id}","starred_url":"https://api.github.com/users/basti1302/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basti1302/subscriptions","organizations_url":"https://api.github.com/users/basti1302/orgs","repos_url":"https://api.github.com/users/basti1302/repos","events_url":"https://api.github.com/users/basti1302/events{/privacy}","received_events_url":"https://api.github.com/users/basti1302/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-01-21T12:42:01Z","updated_at":"2015-01-23T20:45:40Z","closed_at":null,"body":"I'm not getting error callback when OPTIONS call for a CORS request fails.\r\n\r\nI applied a fix to request.js to catch errors.\r\n\r\nI have modified the function below.\r\n\r\nRequest.prototype.get = function(uri, callback) {\r\n  mapRequest(superagent.get(uri), this.options)\r\n    .end(function(response) {\r\n    callback(null, mapResponse(response));  \r\n  });\r\n};\r\n\r\nas  \r\n\r\nRequest.prototype.get = function(uri, callback) {\r\n  mapRequest(superagent.get(uri), this.options)\r\n    .end(handleResponse(callback));\r\n};\r\nvar handleResponse = function(callback) {\r\n  return function(error, data) {\r\n   if (error) {\r\n      return callback(error);\r\n    } else {\r\n      return callback(null, mapResponse(data));\r\n    }\r\n  };\r\n};\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/basti1302/traverson/issues/comments/71262605","html_url":"https://github.com/basti1302/traverson/issues/28#issuecomment-71262605","issue_url":"https://api.github.com/repos/basti1302/traverson/issues/28","id":71262605,"user":{"login":"basti1302","id":73801,"avatar_url":"https://avatars.githubusercontent.com/u/73801?v=3","gravatar_id":"","url":"https://api.github.com/users/basti1302","html_url":"https://github.com/basti1302","followers_url":"https://api.github.com/users/basti1302/followers","following_url":"https://api.github.com/users/basti1302/following{/other_user}","gists_url":"https://api.github.com/users/basti1302/gists{/gist_id}","starred_url":"https://api.github.com/users/basti1302/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basti1302/subscriptions","organizations_url":"https://api.github.com/users/basti1302/orgs","repos_url":"https://api.github.com/users/basti1302/repos","events_url":"https://api.github.com/users/basti1302/events{/privacy}","received_events_url":"https://api.github.com/users/basti1302/received_events","type":"User","site_admin":false},"created_at":"2015-01-23T20:45:40Z","updated_at":"2015-01-23T20:45:40Z","body":"Would you mind sending the modification as a pull request?"}}