{"action":"created","comment":{"url":"https://api.github.com/repos/onaio/milia/pulls/comments/35001402","id":35001402,"diff_hunk":"@@ -0,0 +1,26 @@\n+(ns milia.utils.request\n+  (:require [cljs.core.async :as async :refer [<! put! chan]]\n+            [cljs-http.client :as cljs-http])\n+  (:require-macros [cljs.core.async.macros :refer [go]]))\n+\n+;; The below are matched to API responses\n+(def invalid-token-msg \"Invalid token\")\n+(def token-expired-msg \"Token expired\")\n+\n+(defn request\n+  \"Wraps cljs-http.client/request and redirects if status is 401\"\n+  [& args]\n+  (let [response-channel (chan)]\n+    (go\n+      (let [original-response-channel (apply cljs-http/request args)\n+            {:keys [status] :as response} (<! original-response-channel)]\n+        (condp = status\n+          401 (let [{{detail :detail} :body} response\n+                    reload-page #(set! js/window.location js/window.location)","path":"src/milia/utils/request.cljc","position":19,"original_position":19,"commit_id":"628a423ae2c7f3ea36a76fcad2b17c4b2ab92cbd","original_commit_id":"628a423ae2c7f3ea36a76fcad2b17c4b2ab92cbd","user":{"login":"geoffreymuchai","id":765152,"avatar_url":"https://avatars.githubusercontent.com/u/765152?v=3","gravatar_id":"","url":"https://api.github.com/users/geoffreymuchai","html_url":"https://github.com/geoffreymuchai","followers_url":"https://api.github.com/users/geoffreymuchai/followers","following_url":"https://api.github.com/users/geoffreymuchai/following{/other_user}","gists_url":"https://api.github.com/users/geoffreymuchai/gists{/gist_id}","starred_url":"https://api.github.com/users/geoffreymuchai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geoffreymuchai/subscriptions","organizations_url":"https://api.github.com/users/geoffreymuchai/orgs","repos_url":"https://api.github.com/users/geoffreymuchai/repos","events_url":"https://api.github.com/users/geoffreymuchai/events{/privacy}","received_events_url":"https://api.github.com/users/geoffreymuchai/received_events","type":"User","site_admin":false},"body":"Didn't think much about the file extension since I knew the cljc code would be easily imported into the http file. We can update it to be a cljs file","created_at":"2015-07-20T14:41:16Z","updated_at":"2015-07-20T14:41:16Z","html_url":"https://github.com/onaio/milia/pull/42#discussion_r35001402","pull_request_url":"https://api.github.com/repos/onaio/milia/pulls/42","_links":{"self":{"href":"https://api.github.com/repos/onaio/milia/pulls/comments/35001402"},"html":{"href":"https://github.com/onaio/milia/pull/42#discussion_r35001402"},"pull_request":{"href":"https://api.github.com/repos/onaio/milia/pulls/42"}}},"pull_request":{"url":"https://api.github.com/repos/onaio/milia/pulls/42","id":40357689,"html_url":"https://github.com/onaio/milia/pull/42","diff_url":"https://github.com/onaio/milia/pull/42.diff","patch_url":"https://github.com/onaio/milia/pull/42.patch","issue_url":"https://api.github.com/repos/onaio/milia/issues/42","number":42,"state":"open","locked":false,"title":"1678 authentication popup fix","user":{"login":"royrutto","id":1002419,"avatar_url":"https://avatars.githubusercontent.com/u/1002419?v=3","gravatar_id":"","url":"https://api.github.com/users/royrutto","html_url":"https://github.com/royrutto","followers_url":"https://api.github.com/users/royrutto/followers","following_url":"https://api.github.com/users/royrutto/following{/other_user}","gists_url":"https://api.github.com/users/royrutto/gists{/gist_id}","starred_url":"https://api.github.com/users/royrutto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/royrutto/subscriptions","organizations_url":"https://api.github.com/users/royrutto/orgs","repos_url":"https://api.github.com/users/royrutto/repos","events_url":"https://api.github.com/users/royrutto/events{/privacy}","received_events_url":"https://api.github.com/users/royrutto/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-20T14:30:13Z","updated_at":"2015-07-20T14:41:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"644017966d88a55c7a899ac2aedac95647bb16e0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/onaio/milia/pulls/42/commits","review_comments_url":"https://api.github.com/repos/onaio/milia/pulls/42/comments","review_comment_url":"https://api.github.com/repos/onaio/milia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/onaio/milia/issues/42/comments","statuses_url":"https://api.github.com/repos/onaio/milia/statuses/628a423ae2c7f3ea36a76fcad2b17c4b2ab92cbd","head":{"label":"onaio:1678-authentication-popup-fix","ref":"1678-authentication-popup-fix","sha":"628a423ae2c7f3ea36a76fcad2b17c4b2ab92cbd","user":{"login":"onaio","id":5450613,"avatar_url":"https://avatars.githubusercontent.com/u/5450613?v=3","gravatar_id":"","url":"https://api.github.com/users/onaio","html_url":"https://github.com/onaio","followers_url":"https://api.github.com/users/onaio/followers","following_url":"https://api.github.com/users/onaio/following{/other_user}","gists_url":"https://api.github.com/users/onaio/gists{/gist_id}","starred_url":"https://api.github.com/users/onaio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onaio/subscriptions","organizations_url":"https://api.github.com/users/onaio/orgs","repos_url":"https://api.github.com/users/onaio/repos","events_url":"https://api.github.com/users/onaio/events{/privacy}","received_events_url":"https://api.github.com/users/onaio/received_events","type":"Organization","site_admin":false},"repo":{"id":34326758,"name":"milia","full_name":"onaio/milia","owner":{"login":"onaio","id":5450613,"avatar_url":"https://avatars.githubusercontent.com/u/5450613?v=3","gravatar_id":"","url":"https://api.github.com/users/onaio","html_url":"https://github.com/onaio","followers_url":"https://api.github.com/users/onaio/followers","following_url":"https://api.github.com/users/onaio/following{/other_user}","gists_url":"https://api.github.com/users/onaio/gists{/gist_id}","starred_url":"https://api.github.com/users/onaio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onaio/subscriptions","organizations_url":"https://api.github.com/users/onaio/orgs","repos_url":"https://api.github.com/users/onaio/repos","events_url":"https://api.github.com/users/onaio/events{/privacy}","received_events_url":"https://api.github.com/users/onaio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/onaio/milia","description":"Ona API client library in Clojure and ClojureScript","fork":false,"url":"https://api.github.com/repos/onaio/milia","forks_url":"https://api.github.com/repos/onaio/milia/forks","keys_url":"https://api.github.com/repos/onaio/milia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/onaio/milia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/onaio/milia/teams","hooks_url":"https://api.github.com/repos/onaio/milia/hooks","issue_events_url":"https://api.github.com/repos/onaio/milia/issues/events{/number}","events_url":"https://api.github.com/repos/onaio/milia/events","assignees_url":"https://api.github.com/repos/onaio/milia/assignees{/user}","branches_url":"https://api.github.com/repos/onaio/milia/branches{/branch}","tags_url":"https://api.github.com/repos/onaio/milia/tags","blobs_url":"https://api.github.com/repos/onaio/milia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/onaio/milia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/onaio/milia/git/refs{/sha}","trees_url":"https://api.github.com/repos/onaio/milia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/onaio/milia/statuses/{sha}","languages_url":"https://api.github.com/repos/onaio/milia/languages","stargazers_url":"https://api.github.com/repos/onaio/milia/stargazers","contributors_url":"https://api.github.com/repos/onaio/milia/contributors","subscribers_url":"https://api.github.com/repos/onaio/milia/subscribers","subscription_url":"https://api.github.com/repos/onaio/milia/subscription","commits_url":"https://api.github.com/repos/onaio/milia/commits{/sha}","git_commits_url":"https://api.github.com/repos/onaio/milia/git/commits{/sha}","comments_url":"https://api.github.com/repos/onaio/milia/comments{/number}","issue_comment_url":"https://api.github.com/repos/onaio/milia/issues/comments{/number}","contents_url":"https://api.github.com/repos/onaio/milia/contents/{+path}","compare_url":"https://api.github.com/repos/onaio/milia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/onaio/milia/merges","archive_url":"https://api.github.com/repos/onaio/milia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/onaio/milia/downloads","issues_url":"https://api.github.com/repos/onaio/milia/issues{/number}","pulls_url":"https://api.github.com/repos/onaio/milia/pulls{/number}","milestones_url":"https://api.github.com/repos/onaio/milia/milestones{/number}","notifications_url":"https://api.github.com/repos/onaio/milia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/onaio/milia/labels{/name}","releases_url":"https://api.github.com/repos/onaio/milia/releases{/id}","created_at":"2015-04-21T12:52:45Z","updated_at":"2015-07-06T12:47:42Z","pushed_at":"2015-07-20T14:30:13Z","git_url":"git://github.com/onaio/milia.git","ssh_url":"git@github.com:onaio/milia.git","clone_url":"https://github.com/onaio/milia.git","svn_url":"https://github.com/onaio/milia","homepage":null,"size":629,"stargazers_count":3,"watchers_count":3,"language":"Clojure","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":3,"default_branch":"master"}},"base":{"label":"onaio:master","ref":"master","sha":"b9000e24dfb07a3818f0b3d58bced9f36c4d91bf","user":{"login":"onaio","id":5450613,"avatar_url":"https://avatars.githubusercontent.com/u/5450613?v=3","gravatar_id":"","url":"https://api.github.com/users/onaio","html_url":"https://github.com/onaio","followers_url":"https://api.github.com/users/onaio/followers","following_url":"https://api.github.com/users/onaio/following{/other_user}","gists_url":"https://api.github.com/users/onaio/gists{/gist_id}","starred_url":"https://api.github.com/users/onaio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onaio/subscriptions","organizations_url":"https://api.github.com/users/onaio/orgs","repos_url":"https://api.github.com/users/onaio/repos","events_url":"https://api.github.com/users/onaio/events{/privacy}","received_events_url":"https://api.github.com/users/onaio/received_events","type":"Organization","site_admin":false},"repo":{"id":34326758,"name":"milia","full_name":"onaio/milia","owner":{"login":"onaio","id":5450613,"avatar_url":"https://avatars.githubusercontent.com/u/5450613?v=3","gravatar_id":"","url":"https://api.github.com/users/onaio","html_url":"https://github.com/onaio","followers_url":"https://api.github.com/users/onaio/followers","following_url":"https://api.github.com/users/onaio/following{/other_user}","gists_url":"https://api.github.com/users/onaio/gists{/gist_id}","starred_url":"https://api.github.com/users/onaio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onaio/subscriptions","organizations_url":"https://api.github.com/users/onaio/orgs","repos_url":"https://api.github.com/users/onaio/repos","events_url":"https://api.github.com/users/onaio/events{/privacy}","received_events_url":"https://api.github.com/users/onaio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/onaio/milia","description":"Ona API client library in Clojure and ClojureScript","fork":false,"url":"https://api.github.com/repos/onaio/milia","forks_url":"https://api.github.com/repos/onaio/milia/forks","keys_url":"https://api.github.com/repos/onaio/milia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/onaio/milia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/onaio/milia/teams","hooks_url":"https://api.github.com/repos/onaio/milia/hooks","issue_events_url":"https://api.github.com/repos/onaio/milia/issues/events{/number}","events_url":"https://api.github.com/repos/onaio/milia/events","assignees_url":"https://api.github.com/repos/onaio/milia/assignees{/user}","branches_url":"https://api.github.com/repos/onaio/milia/branches{/branch}","tags_url":"https://api.github.com/repos/onaio/milia/tags","blobs_url":"https://api.github.com/repos/onaio/milia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/onaio/milia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/onaio/milia/git/refs{/sha}","trees_url":"https://api.github.com/repos/onaio/milia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/onaio/milia/statuses/{sha}","languages_url":"https://api.github.com/repos/onaio/milia/languages","stargazers_url":"https://api.github.com/repos/onaio/milia/stargazers","contributors_url":"https://api.github.com/repos/onaio/milia/contributors","subscribers_url":"https://api.github.com/repos/onaio/milia/subscribers","subscription_url":"https://api.github.com/repos/onaio/milia/subscription","commits_url":"https://api.github.com/repos/onaio/milia/commits{/sha}","git_commits_url":"https://api.github.com/repos/onaio/milia/git/commits{/sha}","comments_url":"https://api.github.com/repos/onaio/milia/comments{/number}","issue_comment_url":"https://api.github.com/repos/onaio/milia/issues/comments{/number}","contents_url":"https://api.github.com/repos/onaio/milia/contents/{+path}","compare_url":"https://api.github.com/repos/onaio/milia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/onaio/milia/merges","archive_url":"https://api.github.com/repos/onaio/milia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/onaio/milia/downloads","issues_url":"https://api.github.com/repos/onaio/milia/issues{/number}","pulls_url":"https://api.github.com/repos/onaio/milia/pulls{/number}","milestones_url":"https://api.github.com/repos/onaio/milia/milestones{/number}","notifications_url":"https://api.github.com/repos/onaio/milia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/onaio/milia/labels{/name}","releases_url":"https://api.github.com/repos/onaio/milia/releases{/id}","created_at":"2015-04-21T12:52:45Z","updated_at":"2015-07-06T12:47:42Z","pushed_at":"2015-07-20T14:30:13Z","git_url":"git://github.com/onaio/milia.git","ssh_url":"git@github.com:onaio/milia.git","clone_url":"https://github.com/onaio/milia.git","svn_url":"https://github.com/onaio/milia","homepage":null,"size":629,"stargazers_count":3,"watchers_count":3,"language":"Clojure","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/onaio/milia/pulls/42"},"html":{"href":"https://github.com/onaio/milia/pull/42"},"issue":{"href":"https://api.github.com/repos/onaio/milia/issues/42"},"comments":{"href":"https://api.github.com/repos/onaio/milia/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/onaio/milia/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/onaio/milia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/onaio/milia/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/onaio/milia/statuses/628a423ae2c7f3ea36a76fcad2b17c4b2ab92cbd"}}}}