{"action":"created","comment":{"url":"https://api.github.com/repos/dabapps/redux-requests/pulls/comments/228186336","pull_request_review_id":168399102,"id":228186336,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyODE4NjMzNg==","diff_hunk":"@@ -38,40 +40,58 @@ export function resetRequestState(actionSet: AsyncActionSet, tag: string = '') {\n   };\n }\n \n-export function dispatchGenericRequest(\n+export function requestFromFunction(\n   actionSet: AsyncActionSet,\n-  url: string,\n-  method: UrlMethod,\n-  data?: any,\n-  tag: string = '',\n-  metaData: Partial<RequestMetaData> = {},\n-  headers: Dict<string> = {}\n+  requestBuilder: () => AxiosPromise,\n+  params: RequestParams = {}\n ) {\n+  const { metaData, tag, shouldRethrow } = params;\n+\n   return (dispatch: Dispatch<any>) => {\n-    const meta: RequestMetaData = { ...metaData, tag };\n+    const meta: RequestMetaData = { ...(metaData || {}), tag: tag || '' };\n \n     dispatch({ type: actionSet.REQUEST, meta });\n-    dispatch(setRequestState(actionSet, 'REQUEST', null, tag));\n+    dispatch(setRequestState(actionSet, 'REQUEST', null, tag || ''));\n \n-    return apiRequest(url, method, data, headers)\n-      .then((response: AxiosResponse) => {\n+    return requestBuilder().then(\n+      (response: AxiosResponse) => {\n         dispatch({\n           type: actionSet.SUCCESS,\n           payload: response,\n           meta,\n         });\n-        dispatch(setRequestState(actionSet, 'SUCCESS', response, tag));\n+        dispatch(setRequestState(actionSet, 'SUCCESS', response, tag || ''));\n         return response;\n-      })\n-      .catch((error: AxiosError) => {\n+      },\n+      (error: AxiosError) => {\n         dispatch({\n           type: actionSet.FAILURE,\n           payload: error,\n           meta,\n           error: true,\n         });\n-        dispatch(setRequestState(actionSet, 'FAILURE', error, tag));\n-        return Promise.reject(error);\n-      });\n+        dispatch(setRequestState(actionSet, 'FAILURE', error, tag || ''));\n+\n+        if (shouldRethrow && shouldRethrow(error)) {\n+          return Promise.reject(error);\n+        }\n+        return Promise.resolve();\n+      }\n+    );\n   };\n }\n+\n+export function request(\n+  actionSet: AsyncActionSet,\n+  url: string,\n+  method: UrlMethod,\n+  data?: string | number | Dict<any> | ReadonlyArray<any>,\n+  params: ExtendedRequestParams = {}","path":"src/ts/actions.ts","position":80,"original_position":80,"commit_id":"68dc4bdfc7674dd8d98a7d5078bd0699ea321cce","original_commit_id":"68dc4bdfc7674dd8d98a7d5078bd0699ea321cce","user":{"login":"nvlaarhoven","id":12628901,"node_id":"MDQ6VXNlcjEyNjI4OTAx","avatar_url":"https://avatars1.githubusercontent.com/u/12628901?v=4","gravatar_id":"","url":"https://api.github.com/users/nvlaarhoven","html_url":"https://github.com/nvlaarhoven","followers_url":"https://api.github.com/users/nvlaarhoven/followers","following_url":"https://api.github.com/users/nvlaarhoven/following{/other_user}","gists_url":"https://api.github.com/users/nvlaarhoven/gists{/gist_id}","starred_url":"https://api.github.com/users/nvlaarhoven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nvlaarhoven/subscriptions","organizations_url":"https://api.github.com/users/nvlaarhoven/orgs","repos_url":"https://api.github.com/users/nvlaarhoven/repos","events_url":"https://api.github.com/users/nvlaarhoven/events{/privacy}","received_events_url":"https://api.github.com/users/nvlaarhoven/received_events","type":"User","site_admin":false},"body":"👍 ","created_at":"2018-10-25T14:04:21Z","updated_at":"2018-10-25T14:04:22Z","html_url":"https://github.com/dabapps/redux-requests/pull/20#discussion_r228186336","pull_request_url":"https://api.github.com/repos/dabapps/redux-requests/pulls/20","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/dabapps/redux-requests/pulls/comments/228186336"},"html":{"href":"https://github.com/dabapps/redux-requests/pull/20#discussion_r228186336"},"pull_request":{"href":"https://api.github.com/repos/dabapps/redux-requests/pulls/20"}},"in_reply_to_id":228184661},"pull_request":{"url":"https://api.github.com/repos/dabapps/redux-requests/pulls/20","id":225327511,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI1MzI3NTEx","html_url":"https://github.com/dabapps/redux-requests/pull/20","diff_url":"https://github.com/dabapps/redux-requests/pull/20.diff","patch_url":"https://github.com/dabapps/redux-requests/pull/20.patch","issue_url":"https://api.github.com/repos/dabapps/redux-requests/issues/20","number":20,"state":"open","locked":false,"title":"Nicer Request action dispatching","user":{"login":"AngryLawyer","id":1378607,"node_id":"MDQ6VXNlcjEzNzg2MDc=","avatar_url":"https://avatars2.githubusercontent.com/u/1378607?v=4","gravatar_id":"","url":"https://api.github.com/users/AngryLawyer","html_url":"https://github.com/AngryLawyer","followers_url":"https://api.github.com/users/AngryLawyer/followers","following_url":"https://api.github.com/users/AngryLawyer/following{/other_user}","gists_url":"https://api.github.com/users/AngryLawyer/gists{/gist_id}","starred_url":"https://api.github.com/users/AngryLawyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AngryLawyer/subscriptions","organizations_url":"https://api.github.com/users/AngryLawyer/orgs","repos_url":"https://api.github.com/users/AngryLawyer/repos","events_url":"https://api.github.com/users/AngryLawyer/events{/privacy}","received_events_url":"https://api.github.com/users/AngryLawyer/received_events","type":"User","site_admin":false},"body":"This swaps out dispatchGenericRequest for a much simpler 'request' method, plus 'requestFromFunction' for those wanting finer grained control over how the API is hit.\r\n\r\nIn addition, by default the API will now swallow HTTP errors; you can pass a function to mark when to rethrow errors.\r\n\r\nTODO: Update the README","created_at":"2018-10-24T09:25:23Z","updated_at":"2018-10-25T14:04:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eb47e717c15ed3d634b97c4b324f44065a6e2781","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1037876415,"node_id":"MDU6TGFiZWwxMDM3ODc2NDE1","url":"https://api.github.com/repos/dabapps/redux-requests/labels/review%20needed","name":"review needed","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/dabapps/redux-requests/pulls/20/commits","review_comments_url":"https://api.github.com/repos/dabapps/redux-requests/pulls/20/comments","review_comment_url":"https://api.github.com/repos/dabapps/redux-requests/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dabapps/redux-requests/issues/20/comments","statuses_url":"https://api.github.com/repos/dabapps/redux-requests/statuses/68dc4bdfc7674dd8d98a7d5078bd0699ea321cce","head":{"label":"dabapps:nicer-api","ref":"nicer-api","sha":"68dc4bdfc7674dd8d98a7d5078bd0699ea321cce","user":{"login":"dabapps","id":445568,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0NTU2OA==","avatar_url":"https://avatars2.githubusercontent.com/u/445568?v=4","gravatar_id":"","url":"https://api.github.com/users/dabapps","html_url":"https://github.com/dabapps","followers_url":"https://api.github.com/users/dabapps/followers","following_url":"https://api.github.com/users/dabapps/following{/other_user}","gists_url":"https://api.github.com/users/dabapps/gists{/gist_id}","starred_url":"https://api.github.com/users/dabapps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dabapps/subscriptions","organizations_url":"https://api.github.com/users/dabapps/orgs","repos_url":"https://api.github.com/users/dabapps/repos","events_url":"https://api.github.com/users/dabapps/events{/privacy}","received_events_url":"https://api.github.com/users/dabapps/received_events","type":"Organization","site_admin":false},"repo":{"id":146011556,"node_id":"MDEwOlJlcG9zaXRvcnkxNDYwMTE1NTY=","name":"redux-requests","full_name":"dabapps/redux-requests","private":false,"owner":{"login":"dabapps","id":445568,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0NTU2OA==","avatar_url":"https://avatars2.githubusercontent.com/u/445568?v=4","gravatar_id":"","url":"https://api.github.com/users/dabapps","html_url":"https://github.com/dabapps","followers_url":"https://api.github.com/users/dabapps/followers","following_url":"https://api.github.com/users/dabapps/following{/other_user}","gists_url":"https://api.github.com/users/dabapps/gists{/gist_id}","starred_url":"https://api.github.com/users/dabapps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dabapps/subscriptions","organizations_url":"https://api.github.com/users/dabapps/orgs","repos_url":"https://api.github.com/users/dabapps/repos","events_url":"https://api.github.com/users/dabapps/events{/privacy}","received_events_url":"https://api.github.com/users/dabapps/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/dabapps/redux-requests","description":"Library for simple redux requests","fork":false,"url":"https://api.github.com/repos/dabapps/redux-requests","forks_url":"https://api.github.com/repos/dabapps/redux-requests/forks","keys_url":"https://api.github.com/repos/dabapps/redux-requests/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dabapps/redux-requests/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dabapps/redux-requests/teams","hooks_url":"https://api.github.com/repos/dabapps/redux-requests/hooks","issue_events_url":"https://api.github.com/repos/dabapps/redux-requests/issues/events{/number}","events_url":"https://api.github.com/repos/dabapps/redux-requests/events","assignees_url":"https://api.github.com/repos/dabapps/redux-requests/assignees{/user}","branches_url":"https://api.github.com/repos/dabapps/redux-requests/branches{/branch}","tags_url":"https://api.github.com/repos/dabapps/redux-requests/tags","blobs_url":"https://api.github.com/repos/dabapps/redux-requests/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dabapps/redux-requests/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dabapps/redux-requests/git/refs{/sha}","trees_url":"https://api.github.com/repos/dabapps/redux-requests/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dabapps/redux-requests/statuses/{sha}","languages_url":"https://api.github.com/repos/dabapps/redux-requests/languages","stargazers_url":"https://api.github.com/repos/dabapps/redux-requests/stargazers","contributors_url":"https://api.github.com/repos/dabapps/redux-requests/contributors","subscribers_url":"https://api.github.com/repos/dabapps/redux-requests/subscribers","subscription_url":"https://api.github.com/repos/dabapps/redux-requests/subscription","commits_url":"https://api.github.com/repos/dabapps/redux-requests/commits{/sha}","git_commits_url":"https://api.github.com/repos/dabapps/redux-requests/git/commits{/sha}","comments_url":"https://api.github.com/repos/dabapps/redux-requests/comments{/number}","issue_comment_url":"https://api.github.com/repos/dabapps/redux-requests/issues/comments{/number}","contents_url":"https://api.github.com/repos/dabapps/redux-requests/contents/{+path}","compare_url":"https://api.github.com/repos/dabapps/redux-requests/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dabapps/redux-requests/merges","archive_url":"https://api.github.com/repos/dabapps/redux-requests/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dabapps/redux-requests/downloads","issues_url":"https://api.github.com/repos/dabapps/redux-requests/issues{/number}","pulls_url":"https://api.github.com/repos/dabapps/redux-requests/pulls{/number}","milestones_url":"https://api.github.com/repos/dabapps/redux-requests/milestones{/number}","notifications_url":"https://api.github.com/repos/dabapps/redux-requests/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dabapps/redux-requests/labels{/name}","releases_url":"https://api.github.com/repos/dabapps/redux-requests/releases{/id}","deployments_url":"https://api.github.com/repos/dabapps/redux-requests/deployments","created_at":"2018-08-24T15:55:39Z","updated_at":"2018-10-17T15:51:04Z","pushed_at":"2018-10-25T13:50:57Z","git_url":"git://github.com/dabapps/redux-requests.git","ssh_url":"git@github.com:dabapps/redux-requests.git","clone_url":"https://github.com/dabapps/redux-requests.git","svn_url":"https://github.com/dabapps/redux-requests","homepage":"","size":270,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"dabapps:master","ref":"master","sha":"dc4c45096667c1fe40abeef14434ba126a85a94b","user":{"login":"dabapps","id":445568,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0NTU2OA==","avatar_url":"https://avatars2.githubusercontent.com/u/445568?v=4","gravatar_id":"","url":"https://api.github.com/users/dabapps","html_url":"https://github.com/dabapps","followers_url":"https://api.github.com/users/dabapps/followers","following_url":"https://api.github.com/users/dabapps/following{/other_user}","gists_url":"https://api.github.com/users/dabapps/gists{/gist_id}","starred_url":"https://api.github.com/users/dabapps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dabapps/subscriptions","organizations_url":"https://api.github.com/users/dabapps/orgs","repos_url":"https://api.github.com/users/dabapps/repos","events_url":"https://api.github.com/users/dabapps/events{/privacy}","received_events_url":"https://api.github.com/users/dabapps/received_events","type":"Organization","site_admin":false},"repo":{"id":146011556,"node_id":"MDEwOlJlcG9zaXRvcnkxNDYwMTE1NTY=","name":"redux-requests","full_name":"dabapps/redux-requests","private":false,"owner":{"login":"dabapps","id":445568,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0NTU2OA==","avatar_url":"https://avatars2.githubusercontent.com/u/445568?v=4","gravatar_id":"","url":"https://api.github.com/users/dabapps","html_url":"https://github.com/dabapps","followers_url":"https://api.github.com/users/dabapps/followers","following_url":"https://api.github.com/users/dabapps/following{/other_user}","gists_url":"https://api.github.com/users/dabapps/gists{/gist_id}","starred_url":"https://api.github.com/users/dabapps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dabapps/subscriptions","organizations_url":"https://api.github.com/users/dabapps/orgs","repos_url":"https://api.github.com/users/dabapps/repos","events_url":"https://api.github.com/users/dabapps/events{/privacy}","received_events_url":"https://api.github.com/users/dabapps/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/dabapps/redux-requests","description":"Library for simple redux requests","fork":false,"url":"https://api.github.com/repos/dabapps/redux-requests","forks_url":"https://api.github.com/repos/dabapps/redux-requests/forks","keys_url":"https://api.github.com/repos/dabapps/redux-requests/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dabapps/redux-requests/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dabapps/redux-requests/teams","hooks_url":"https://api.github.com/repos/dabapps/redux-requests/hooks","issue_events_url":"https://api.github.com/repos/dabapps/redux-requests/issues/events{/number}","events_url":"https://api.github.com/repos/dabapps/redux-requests/events","assignees_url":"https://api.github.com/repos/dabapps/redux-requests/assignees{/user}","branches_url":"https://api.github.com/repos/dabapps/redux-requests/branches{/branch}","tags_url":"https://api.github.com/repos/dabapps/redux-requests/tags","blobs_url":"https://api.github.com/repos/dabapps/redux-requests/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dabapps/redux-requests/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dabapps/redux-requests/git/refs{/sha}","trees_url":"https://api.github.com/repos/dabapps/redux-requests/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dabapps/redux-requests/statuses/{sha}","languages_url":"https://api.github.com/repos/dabapps/redux-requests/languages","stargazers_url":"https://api.github.com/repos/dabapps/redux-requests/stargazers","contributors_url":"https://api.github.com/repos/dabapps/redux-requests/contributors","subscribers_url":"https://api.github.com/repos/dabapps/redux-requests/subscribers","subscription_url":"https://api.github.com/repos/dabapps/redux-requests/subscription","commits_url":"https://api.github.com/repos/dabapps/redux-requests/commits{/sha}","git_commits_url":"https://api.github.com/repos/dabapps/redux-requests/git/commits{/sha}","comments_url":"https://api.github.com/repos/dabapps/redux-requests/comments{/number}","issue_comment_url":"https://api.github.com/repos/dabapps/redux-requests/issues/comments{/number}","contents_url":"https://api.github.com/repos/dabapps/redux-requests/contents/{+path}","compare_url":"https://api.github.com/repos/dabapps/redux-requests/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dabapps/redux-requests/merges","archive_url":"https://api.github.com/repos/dabapps/redux-requests/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dabapps/redux-requests/downloads","issues_url":"https://api.github.com/repos/dabapps/redux-requests/issues{/number}","pulls_url":"https://api.github.com/repos/dabapps/redux-requests/pulls{/number}","milestones_url":"https://api.github.com/repos/dabapps/redux-requests/milestones{/number}","notifications_url":"https://api.github.com/repos/dabapps/redux-requests/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dabapps/redux-requests/labels{/name}","releases_url":"https://api.github.com/repos/dabapps/redux-requests/releases{/id}","deployments_url":"https://api.github.com/repos/dabapps/redux-requests/deployments","created_at":"2018-08-24T15:55:39Z","updated_at":"2018-10-17T15:51:04Z","pushed_at":"2018-10-25T13:50:57Z","git_url":"git://github.com/dabapps/redux-requests.git","ssh_url":"git@github.com:dabapps/redux-requests.git","clone_url":"https://github.com/dabapps/redux-requests.git","svn_url":"https://github.com/dabapps/redux-requests","homepage":"","size":270,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dabapps/redux-requests/pulls/20"},"html":{"href":"https://github.com/dabapps/redux-requests/pull/20"},"issue":{"href":"https://api.github.com/repos/dabapps/redux-requests/issues/20"},"comments":{"href":"https://api.github.com/repos/dabapps/redux-requests/issues/20/comments"},"review_comments":{"href":"https://api.github.com/repos/dabapps/redux-requests/pulls/20/comments"},"review_comment":{"href":"https://api.github.com/repos/dabapps/redux-requests/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dabapps/redux-requests/pulls/20/commits"},"statuses":{"href":"https://api.github.com/repos/dabapps/redux-requests/statuses/68dc4bdfc7674dd8d98a7d5078bd0699ea321cce"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"nvlaarhoven"}}