{"action":"created","comment":{"url":"https://api.github.com/repos/goodeggs/json-fetch/pulls/comments/87112724","pull_request_review_id":7736065,"id":87112724,"diff_hunk":"@@ -1,61 +1,210 @@\n import chai from 'chai'\n+import sinon from 'sinon';\n import nock from 'nock'\n import es6promise from 'es6-promise'\n const expect = chai.expect\n \n es6promise.polyfill()\n-import jsonFetch from '..'\n+import jsonFetch, {retriers} from '..'\n \n describe('jsonFetch',() => {\n-  it('resolves with json body for 200-level status codes', () => {\n-    nock('http://www.test.com')\n-      .get('/products/1234')\n-      .reply(200, {name: 'apple'})\n-    return jsonFetch('http://www.test.com/products/1234').then((response) => {\n-      expect(response.body).to.deep.equal({name: 'apple'})\n-      expect(response.status).to.equal(200)\n-      expect(response.statusText).to.equal('OK')\n-      expect(response.headers).to.be.ok\n+  describe('single request with no retry', () => {\n+    it('resolves with json body for 200-level status codes', () => {\n+      nock('http://www.test.com')\n+        .get('/products/1234')\n+        .reply(200, {name: 'apple'})\n+      return jsonFetch('http://www.test.com/products/1234').then((response) => {\n+        expect(response.body).to.deep.equal({name: 'apple'})\n+        expect(response.status).to.equal(200)\n+        expect(response.statusText).to.equal('OK')\n+        expect(response.headers).to.be.ok\n+      })\n     })\n-  })\n \n-  it('resolves with undefined for 404 status code', () => {\n-    nock('http://www.test.com')\n-      .get('/products/1234')\n-      .reply(404, 'not found')\n-    return jsonFetch('http://www.test.com/products/1234').then((response) => {\n-      expect(response.body).to.equal(undefined)\n-      expect(response.status).to.equal(404)\n-      expect(response.statusText).to.equal('Not Found')\n-      expect(response.headers).to.be.ok\n+    it('resolves with undefined for 404 status code', () => {","path":"test/test.js","position":44,"original_position":44,"commit_id":"ee32c936d482e8506274e2241de651207f83ddf1","original_commit_id":"ee32c936d482e8506274e2241de651207f83ddf1","user":{"login":"dannynelson","id":4513678,"avatar_url":"https://avatars.githubusercontent.com/u/4513678?v=3","gravatar_id":"","url":"https://api.github.com/users/dannynelson","html_url":"https://github.com/dannynelson","followers_url":"https://api.github.com/users/dannynelson/followers","following_url":"https://api.github.com/users/dannynelson/following{/other_user}","gists_url":"https://api.github.com/users/dannynelson/gists{/gist_id}","starred_url":"https://api.github.com/users/dannynelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dannynelson/subscriptions","organizations_url":"https://api.github.com/users/dannynelson/orgs","repos_url":"https://api.github.com/users/dannynelson/repos","events_url":"https://api.github.com/users/dannynelson/events{/privacy}","received_events_url":"https://api.github.com/users/dannynelson/received_events","type":"User","site_admin":false},"body":"Do you think 404s should error too? I think it makes sense error if an endpoint doesn't exist. We could return `null` if the endpoint does exist but it has an empty response.","created_at":"2016-11-09T00:09:34Z","updated_at":"2016-11-09T00:10:37Z","html_url":"https://github.com/goodeggs/json-fetch/pull/4#discussion_r87112724","pull_request_url":"https://api.github.com/repos/goodeggs/json-fetch/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/goodeggs/json-fetch/pulls/comments/87112724"},"html":{"href":"https://github.com/goodeggs/json-fetch/pull/4#discussion_r87112724"},"pull_request":{"href":"https://api.github.com/repos/goodeggs/json-fetch/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/goodeggs/json-fetch/pulls/4","id":92875473,"html_url":"https://github.com/goodeggs/json-fetch/pull/4","diff_url":"https://github.com/goodeggs/json-fetch/pull/4.diff","patch_url":"https://github.com/goodeggs/json-fetch/pull/4.patch","issue_url":"https://api.github.com/repos/goodeggs/json-fetch/issues/4","number":4,"state":"open","locked":false,"title":"Restore retries","user":{"login":"dlau","id":2764274,"avatar_url":"https://avatars.githubusercontent.com/u/2764274?v=3","gravatar_id":"","url":"https://api.github.com/users/dlau","html_url":"https://github.com/dlau","followers_url":"https://api.github.com/users/dlau/followers","following_url":"https://api.github.com/users/dlau/following{/other_user}","gists_url":"https://api.github.com/users/dlau/gists{/gist_id}","starred_url":"https://api.github.com/users/dlau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlau/subscriptions","organizations_url":"https://api.github.com/users/dlau/orgs","repos_url":"https://api.github.com/users/dlau/repos","events_url":"https://api.github.com/users/dlau/events{/privacy}","received_events_url":"https://api.github.com/users/dlau/received_events","type":"User","site_admin":false},"body":"This commit reinstates the promise-retry dependency which provides\r\ntimeouts, exponential backoff, and retry functionality. In this\r\nimplementation, retry functionality is opt-in, meaning no retries will\r\nbe tried unless you explicitly request them.\r\n\r\nWe've wrapped promise-retry to handle all the heavy lifting of retry.\r\nYou can pass options to promise-retry (such as the exponent for\r\nexponential backoff, and delay between attempts) by using a special\r\noption `retry`.\r\n\r\nRather than constrain when to retry requests, we'll simply call the\r\nfunction you provide inside the retry options `shouldRety` with the\r\nFetchResponse or Error (such as ECONNRESET). If that\r\nfunction returns true, we'll retry. If false, we resolve or reject.\r\n\r\nUsage example (see readme for more):\r\n\r\n```\r\njsonFetch('http://www.test.com/products/1234', {\r\n  method: 'POST',\r\n  body: {name: 'apple'},\r\n  retry: {\r\n    // Retry 5 times, in addition to the original request\r\n    retries: 5,\r\n\r\n    // after every request, decide whether or not to make another request\r\n    shouldRetry: retries.isNetworkError\r\n  }\r\n}).then(response => {\r\n  // handle 200-level responses:\r\n});\r\n```\r\ncc @brycefisher  @goodeggs/shopping-web ","created_at":"2016-11-08T22:50:04Z","updated_at":"2016-11-09T00:10:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"09ab7f63fe25d5239821ee69bbeb1b54a5e8e3b4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/goodeggs/json-fetch/pulls/4/commits","review_comments_url":"https://api.github.com/repos/goodeggs/json-fetch/pulls/4/comments","review_comment_url":"https://api.github.com/repos/goodeggs/json-fetch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/goodeggs/json-fetch/issues/4/comments","statuses_url":"https://api.github.com/repos/goodeggs/json-fetch/statuses/ee32c936d482e8506274e2241de651207f83ddf1","head":{"label":"goodeggs:restore-retries","ref":"restore-retries","sha":"ee32c936d482e8506274e2241de651207f83ddf1","user":{"login":"goodeggs","id":892928,"avatar_url":"https://avatars.githubusercontent.com/u/892928?v=3","gravatar_id":"","url":"https://api.github.com/users/goodeggs","html_url":"https://github.com/goodeggs","followers_url":"https://api.github.com/users/goodeggs/followers","following_url":"https://api.github.com/users/goodeggs/following{/other_user}","gists_url":"https://api.github.com/users/goodeggs/gists{/gist_id}","starred_url":"https://api.github.com/users/goodeggs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goodeggs/subscriptions","organizations_url":"https://api.github.com/users/goodeggs/orgs","repos_url":"https://api.github.com/users/goodeggs/repos","events_url":"https://api.github.com/users/goodeggs/events{/privacy}","received_events_url":"https://api.github.com/users/goodeggs/received_events","type":"Organization","site_admin":false},"repo":{"id":49787945,"name":"json-fetch","full_name":"goodeggs/json-fetch","owner":{"login":"goodeggs","id":892928,"avatar_url":"https://avatars.githubusercontent.com/u/892928?v=3","gravatar_id":"","url":"https://api.github.com/users/goodeggs","html_url":"https://github.com/goodeggs","followers_url":"https://api.github.com/users/goodeggs/followers","following_url":"https://api.github.com/users/goodeggs/following{/other_user}","gists_url":"https://api.github.com/users/goodeggs/gists{/gist_id}","starred_url":"https://api.github.com/users/goodeggs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goodeggs/subscriptions","organizations_url":"https://api.github.com/users/goodeggs/orgs","repos_url":"https://api.github.com/users/goodeggs/repos","events_url":"https://api.github.com/users/goodeggs/events{/privacy}","received_events_url":"https://api.github.com/users/goodeggs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/goodeggs/json-fetch","description":"A wrapper around ES6 fetch to simplify interacting with JSON APIs.","fork":false,"url":"https://api.github.com/repos/goodeggs/json-fetch","forks_url":"https://api.github.com/repos/goodeggs/json-fetch/forks","keys_url":"https://api.github.com/repos/goodeggs/json-fetch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/goodeggs/json-fetch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/goodeggs/json-fetch/teams","hooks_url":"https://api.github.com/repos/goodeggs/json-fetch/hooks","issue_events_url":"https://api.github.com/repos/goodeggs/json-fetch/issues/events{/number}","events_url":"https://api.github.com/repos/goodeggs/json-fetch/events","assignees_url":"https://api.github.com/repos/goodeggs/json-fetch/assignees{/user}","branches_url":"https://api.github.com/repos/goodeggs/json-fetch/branches{/branch}","tags_url":"https://api.github.com/repos/goodeggs/json-fetch/tags","blobs_url":"https://api.github.com/repos/goodeggs/json-fetch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/goodeggs/json-fetch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/goodeggs/json-fetch/git/refs{/sha}","trees_url":"https://api.github.com/repos/goodeggs/json-fetch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/goodeggs/json-fetch/statuses/{sha}","languages_url":"https://api.github.com/repos/goodeggs/json-fetch/languages","stargazers_url":"https://api.github.com/repos/goodeggs/json-fetch/stargazers","contributors_url":"https://api.github.com/repos/goodeggs/json-fetch/contributors","subscribers_url":"https://api.github.com/repos/goodeggs/json-fetch/subscribers","subscription_url":"https://api.github.com/repos/goodeggs/json-fetch/subscription","commits_url":"https://api.github.com/repos/goodeggs/json-fetch/commits{/sha}","git_commits_url":"https://api.github.com/repos/goodeggs/json-fetch/git/commits{/sha}","comments_url":"https://api.github.com/repos/goodeggs/json-fetch/comments{/number}","issue_comment_url":"https://api.github.com/repos/goodeggs/json-fetch/issues/comments{/number}","contents_url":"https://api.github.com/repos/goodeggs/json-fetch/contents/{+path}","compare_url":"https://api.github.com/repos/goodeggs/json-fetch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/goodeggs/json-fetch/merges","archive_url":"https://api.github.com/repos/goodeggs/json-fetch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/goodeggs/json-fetch/downloads","issues_url":"https://api.github.com/repos/goodeggs/json-fetch/issues{/number}","pulls_url":"https://api.github.com/repos/goodeggs/json-fetch/pulls{/number}","milestones_url":"https://api.github.com/repos/goodeggs/json-fetch/milestones{/number}","notifications_url":"https://api.github.com/repos/goodeggs/json-fetch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/goodeggs/json-fetch/labels{/name}","releases_url":"https://api.github.com/repos/goodeggs/json-fetch/releases{/id}","deployments_url":"https://api.github.com/repos/goodeggs/json-fetch/deployments","created_at":"2016-01-16T19:36:33Z","updated_at":"2016-09-02T06:27:21Z","pushed_at":"2016-11-08T22:50:04Z","git_url":"git://github.com/goodeggs/json-fetch.git","ssh_url":"git@github.com:goodeggs/json-fetch.git","clone_url":"https://github.com/goodeggs/json-fetch.git","svn_url":"https://github.com/goodeggs/json-fetch","homepage":null,"size":15,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":6,"default_branch":"master"}},"base":{"label":"goodeggs:master","ref":"master","sha":"2b224479fbf0f5553237b09d339c6a882c41d7b9","user":{"login":"goodeggs","id":892928,"avatar_url":"https://avatars.githubusercontent.com/u/892928?v=3","gravatar_id":"","url":"https://api.github.com/users/goodeggs","html_url":"https://github.com/goodeggs","followers_url":"https://api.github.com/users/goodeggs/followers","following_url":"https://api.github.com/users/goodeggs/following{/other_user}","gists_url":"https://api.github.com/users/goodeggs/gists{/gist_id}","starred_url":"https://api.github.com/users/goodeggs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goodeggs/subscriptions","organizations_url":"https://api.github.com/users/goodeggs/orgs","repos_url":"https://api.github.com/users/goodeggs/repos","events_url":"https://api.github.com/users/goodeggs/events{/privacy}","received_events_url":"https://api.github.com/users/goodeggs/received_events","type":"Organization","site_admin":false},"repo":{"id":49787945,"name":"json-fetch","full_name":"goodeggs/json-fetch","owner":{"login":"goodeggs","id":892928,"avatar_url":"https://avatars.githubusercontent.com/u/892928?v=3","gravatar_id":"","url":"https://api.github.com/users/goodeggs","html_url":"https://github.com/goodeggs","followers_url":"https://api.github.com/users/goodeggs/followers","following_url":"https://api.github.com/users/goodeggs/following{/other_user}","gists_url":"https://api.github.com/users/goodeggs/gists{/gist_id}","starred_url":"https://api.github.com/users/goodeggs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goodeggs/subscriptions","organizations_url":"https://api.github.com/users/goodeggs/orgs","repos_url":"https://api.github.com/users/goodeggs/repos","events_url":"https://api.github.com/users/goodeggs/events{/privacy}","received_events_url":"https://api.github.com/users/goodeggs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/goodeggs/json-fetch","description":"A wrapper around ES6 fetch to simplify interacting with JSON APIs.","fork":false,"url":"https://api.github.com/repos/goodeggs/json-fetch","forks_url":"https://api.github.com/repos/goodeggs/json-fetch/forks","keys_url":"https://api.github.com/repos/goodeggs/json-fetch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/goodeggs/json-fetch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/goodeggs/json-fetch/teams","hooks_url":"https://api.github.com/repos/goodeggs/json-fetch/hooks","issue_events_url":"https://api.github.com/repos/goodeggs/json-fetch/issues/events{/number}","events_url":"https://api.github.com/repos/goodeggs/json-fetch/events","assignees_url":"https://api.github.com/repos/goodeggs/json-fetch/assignees{/user}","branches_url":"https://api.github.com/repos/goodeggs/json-fetch/branches{/branch}","tags_url":"https://api.github.com/repos/goodeggs/json-fetch/tags","blobs_url":"https://api.github.com/repos/goodeggs/json-fetch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/goodeggs/json-fetch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/goodeggs/json-fetch/git/refs{/sha}","trees_url":"https://api.github.com/repos/goodeggs/json-fetch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/goodeggs/json-fetch/statuses/{sha}","languages_url":"https://api.github.com/repos/goodeggs/json-fetch/languages","stargazers_url":"https://api.github.com/repos/goodeggs/json-fetch/stargazers","contributors_url":"https://api.github.com/repos/goodeggs/json-fetch/contributors","subscribers_url":"https://api.github.com/repos/goodeggs/json-fetch/subscribers","subscription_url":"https://api.github.com/repos/goodeggs/json-fetch/subscription","commits_url":"https://api.github.com/repos/goodeggs/json-fetch/commits{/sha}","git_commits_url":"https://api.github.com/repos/goodeggs/json-fetch/git/commits{/sha}","comments_url":"https://api.github.com/repos/goodeggs/json-fetch/comments{/number}","issue_comment_url":"https://api.github.com/repos/goodeggs/json-fetch/issues/comments{/number}","contents_url":"https://api.github.com/repos/goodeggs/json-fetch/contents/{+path}","compare_url":"https://api.github.com/repos/goodeggs/json-fetch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/goodeggs/json-fetch/merges","archive_url":"https://api.github.com/repos/goodeggs/json-fetch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/goodeggs/json-fetch/downloads","issues_url":"https://api.github.com/repos/goodeggs/json-fetch/issues{/number}","pulls_url":"https://api.github.com/repos/goodeggs/json-fetch/pulls{/number}","milestones_url":"https://api.github.com/repos/goodeggs/json-fetch/milestones{/number}","notifications_url":"https://api.github.com/repos/goodeggs/json-fetch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/goodeggs/json-fetch/labels{/name}","releases_url":"https://api.github.com/repos/goodeggs/json-fetch/releases{/id}","deployments_url":"https://api.github.com/repos/goodeggs/json-fetch/deployments","created_at":"2016-01-16T19:36:33Z","updated_at":"2016-09-02T06:27:21Z","pushed_at":"2016-11-08T22:50:04Z","git_url":"git://github.com/goodeggs/json-fetch.git","ssh_url":"git@github.com:goodeggs/json-fetch.git","clone_url":"https://github.com/goodeggs/json-fetch.git","svn_url":"https://github.com/goodeggs/json-fetch","homepage":null,"size":15,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/goodeggs/json-fetch/pulls/4"},"html":{"href":"https://github.com/goodeggs/json-fetch/pull/4"},"issue":{"href":"https://api.github.com/repos/goodeggs/json-fetch/issues/4"},"comments":{"href":"https://api.github.com/repos/goodeggs/json-fetch/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/goodeggs/json-fetch/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/goodeggs/json-fetch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/goodeggs/json-fetch/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/goodeggs/json-fetch/statuses/ee32c936d482e8506274e2241de651207f83ddf1"}}}}
{"actor":{"display_login":"dannynelson"}}