{"action":"created","comment":{"url":"https://api.github.com/repos/phovea/phovea_core/pulls/comments/88788607","pull_request_review_id":9353448,"id":88788607,"diff_hunk":"@@ -6,27 +6,42 @@\n /**\n  * Created by Samuel Gratzl on 04.08.2014.\n  */\n-import {list as listPlugins} from './plugin';\n import {offline as isOffline, server_url, server_json_suffix} from '.';\n \n-/**\n- * interface for the ajax adapter\n- */\n-export interface IAjaxAdapter {\n-  send(url: string, data: any, method : string, expectedDataType : string): Promise<any>;\n+class AjaxError extends Error {\n+  constructor(public response: any) {\n+    super(response.statusText);\n+  }\n }\n \n-var _impl : Promise<IAjaxAdapter> = null;\n-\n-function getConnector() {\n-  if (_impl != null) {\n-    return _impl;\n+function checkStatus(response) {\n+  if (response.ok) {\n+    return response;\n+  } else {\n+    throw new AjaxError(response);\n   }\n-  const adapters = listPlugins('ajax-adapter');\n-  var adapter = adapters[0];\n-  return _impl = adapter.load().then((p) => <IAjaxAdapter>p.factory());\n }\n \n+function parseType(expectedDataType: string, response) {\n+  expectedDataType = expectedDataType.trim().toLowerCase();\n+  switch (expectedDataType) {\n+    case 'json':\n+    case 'application/json':\n+      return response.json();\n+    case 'text':\n+    case 'text/plain':\n+      return response.text();\n+    case 'blob':\n+      return response.blob();\n+    case 'formdata':\n+      return response.formData();\n+    case 'arraybuffer':\n+      return response.arrayBuffer();\n+    default:\n+      console.warn('unknown expected data type: ' + expectedDataType + ' returning blob');\n+      return response.blob();\n+  }\n+}","path":"src/ajax.ts","position":53,"original_position":53,"commit_id":"49c65f222221e7cd2ffa2b1d2599ee152a8ed243","original_commit_id":"49c65f222221e7cd2ffa2b1d2599ee152a8ed243","user":{"login":"mccalluc","id":730388,"avatar_url":"https://avatars.githubusercontent.com/u/730388?v=3","gravatar_id":"","url":"https://api.github.com/users/mccalluc","html_url":"https://github.com/mccalluc","followers_url":"https://api.github.com/users/mccalluc/followers","following_url":"https://api.github.com/users/mccalluc/following{/other_user}","gists_url":"https://api.github.com/users/mccalluc/gists{/gist_id}","starred_url":"https://api.github.com/users/mccalluc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mccalluc/subscriptions","organizations_url":"https://api.github.com/users/mccalluc/orgs","repos_url":"https://api.github.com/users/mccalluc/repos","events_url":"https://api.github.com/users/mccalluc/events{/privacy}","received_events_url":"https://api.github.com/users/mccalluc/received_events","type":"User","site_admin":false},"body":"If this is for our own use, do we need to support so many formats? And if someone specifies a type we don't recognize, would be be better to fail explicitly now, rather than returning a result they might or might not be able to handle... when the error finally does break something it will be farther from the point where the mistake was made?","created_at":"2016-11-19T21:45:23Z","updated_at":"2016-11-19T21:45:23Z","html_url":"https://github.com/phovea/phovea_core/pull/15#discussion_r88788607","pull_request_url":"https://api.github.com/repos/phovea/phovea_core/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/phovea/phovea_core/pulls/comments/88788607"},"html":{"href":"https://github.com/phovea/phovea_core/pull/15#discussion_r88788607"},"pull_request":{"href":"https://api.github.com/repos/phovea/phovea_core/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/phovea/phovea_core/pulls/15","id":93717796,"html_url":"https://github.com/phovea/phovea_core/pull/15","diff_url":"https://github.com/phovea/phovea_core/pull/15.diff","patch_url":"https://github.com/phovea/phovea_core/pull/15.patch","issue_url":"https://api.github.com/repos/phovea/phovea_core/issues/15","number":15,"state":"open","locked":false,"title":"Feature 10 fetch api","user":{"login":"sgratzl","id":4129778,"avatar_url":"https://avatars.githubusercontent.com/u/4129778?v=3","gravatar_id":"","url":"https://api.github.com/users/sgratzl","html_url":"https://github.com/sgratzl","followers_url":"https://api.github.com/users/sgratzl/followers","following_url":"https://api.github.com/users/sgratzl/following{/other_user}","gists_url":"https://api.github.com/users/sgratzl/gists{/gist_id}","starred_url":"https://api.github.com/users/sgratzl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgratzl/subscriptions","organizations_url":"https://api.github.com/users/sgratzl/orgs","repos_url":"https://api.github.com/users/sgratzl/repos","events_url":"https://api.github.com/users/sgratzl/events{/privacy}","received_events_url":"https://api.github.com/users/sgratzl/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-15T08:04:12Z","updated_at":"2016-11-19T21:45:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cdcee27efce9ca8b1d115fe51b1bfacb81d81dbf","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/phovea/phovea_core/pulls/15/commits","review_comments_url":"https://api.github.com/repos/phovea/phovea_core/pulls/15/comments","review_comment_url":"https://api.github.com/repos/phovea/phovea_core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/phovea/phovea_core/issues/15/comments","statuses_url":"https://api.github.com/repos/phovea/phovea_core/statuses/49c65f222221e7cd2ffa2b1d2599ee152a8ed243","head":{"label":"phovea:feature_10_fetch_api","ref":"feature_10_fetch_api","sha":"49c65f222221e7cd2ffa2b1d2599ee152a8ed243","user":{"login":"phovea","id":21689003,"avatar_url":"https://avatars.githubusercontent.com/u/21689003?v=3","gravatar_id":"","url":"https://api.github.com/users/phovea","html_url":"https://github.com/phovea","followers_url":"https://api.github.com/users/phovea/followers","following_url":"https://api.github.com/users/phovea/following{/other_user}","gists_url":"https://api.github.com/users/phovea/gists{/gist_id}","starred_url":"https://api.github.com/users/phovea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phovea/subscriptions","organizations_url":"https://api.github.com/users/phovea/orgs","repos_url":"https://api.github.com/users/phovea/repos","events_url":"https://api.github.com/users/phovea/events{/privacy}","received_events_url":"https://api.github.com/users/phovea/received_events","type":"Organization","site_admin":false},"repo":{"id":39556332,"name":"phovea_core","full_name":"phovea/phovea_core","owner":{"login":"phovea","id":21689003,"avatar_url":"https://avatars.githubusercontent.com/u/21689003?v=3","gravatar_id":"","url":"https://api.github.com/users/phovea","html_url":"https://github.com/phovea","followers_url":"https://api.github.com/users/phovea/followers","following_url":"https://api.github.com/users/phovea/following{/other_user}","gists_url":"https://api.github.com/users/phovea/gists{/gist_id}","starred_url":"https://api.github.com/users/phovea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phovea/subscriptions","organizations_url":"https://api.github.com/users/phovea/orgs","repos_url":"https://api.github.com/users/phovea/repos","events_url":"https://api.github.com/users/phovea/events{/privacy}","received_events_url":"https://api.github.com/users/phovea/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/phovea/phovea_core","description":"Phovea core includes the plugin registry, data definition (+ common types: tables, matrix, vector, stratification), ajax, selections","fork":false,"url":"https://api.github.com/repos/phovea/phovea_core","forks_url":"https://api.github.com/repos/phovea/phovea_core/forks","keys_url":"https://api.github.com/repos/phovea/phovea_core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phovea/phovea_core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phovea/phovea_core/teams","hooks_url":"https://api.github.com/repos/phovea/phovea_core/hooks","issue_events_url":"https://api.github.com/repos/phovea/phovea_core/issues/events{/number}","events_url":"https://api.github.com/repos/phovea/phovea_core/events","assignees_url":"https://api.github.com/repos/phovea/phovea_core/assignees{/user}","branches_url":"https://api.github.com/repos/phovea/phovea_core/branches{/branch}","tags_url":"https://api.github.com/repos/phovea/phovea_core/tags","blobs_url":"https://api.github.com/repos/phovea/phovea_core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phovea/phovea_core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phovea/phovea_core/git/refs{/sha}","trees_url":"https://api.github.com/repos/phovea/phovea_core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phovea/phovea_core/statuses/{sha}","languages_url":"https://api.github.com/repos/phovea/phovea_core/languages","stargazers_url":"https://api.github.com/repos/phovea/phovea_core/stargazers","contributors_url":"https://api.github.com/repos/phovea/phovea_core/contributors","subscribers_url":"https://api.github.com/repos/phovea/phovea_core/subscribers","subscription_url":"https://api.github.com/repos/phovea/phovea_core/subscription","commits_url":"https://api.github.com/repos/phovea/phovea_core/commits{/sha}","git_commits_url":"https://api.github.com/repos/phovea/phovea_core/git/commits{/sha}","comments_url":"https://api.github.com/repos/phovea/phovea_core/comments{/number}","issue_comment_url":"https://api.github.com/repos/phovea/phovea_core/issues/comments{/number}","contents_url":"https://api.github.com/repos/phovea/phovea_core/contents/{+path}","compare_url":"https://api.github.com/repos/phovea/phovea_core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phovea/phovea_core/merges","archive_url":"https://api.github.com/repos/phovea/phovea_core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phovea/phovea_core/downloads","issues_url":"https://api.github.com/repos/phovea/phovea_core/issues{/number}","pulls_url":"https://api.github.com/repos/phovea/phovea_core/pulls{/number}","milestones_url":"https://api.github.com/repos/phovea/phovea_core/milestones{/number}","notifications_url":"https://api.github.com/repos/phovea/phovea_core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phovea/phovea_core/labels{/name}","releases_url":"https://api.github.com/repos/phovea/phovea_core/releases{/id}","deployments_url":"https://api.github.com/repos/phovea/phovea_core/deployments","created_at":"2015-07-23T08:49:28Z","updated_at":"2016-11-06T09:27:39Z","pushed_at":"2016-11-19T21:36:08Z","git_url":"git://github.com/phovea/phovea_core.git","ssh_url":"git@github.com:phovea/phovea_core.git","clone_url":"https://github.com/phovea/phovea_core.git","svn_url":"https://github.com/phovea/phovea_core","homepage":"http://phovea.caleydo.org/","size":406,"stargazers_count":4,"watchers_count":4,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":4,"default_branch":"master"}},"base":{"label":"phovea:master","ref":"master","sha":"3d411fe47996027c1e0959241c03e516d6c56ad1","user":{"login":"phovea","id":21689003,"avatar_url":"https://avatars.githubusercontent.com/u/21689003?v=3","gravatar_id":"","url":"https://api.github.com/users/phovea","html_url":"https://github.com/phovea","followers_url":"https://api.github.com/users/phovea/followers","following_url":"https://api.github.com/users/phovea/following{/other_user}","gists_url":"https://api.github.com/users/phovea/gists{/gist_id}","starred_url":"https://api.github.com/users/phovea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phovea/subscriptions","organizations_url":"https://api.github.com/users/phovea/orgs","repos_url":"https://api.github.com/users/phovea/repos","events_url":"https://api.github.com/users/phovea/events{/privacy}","received_events_url":"https://api.github.com/users/phovea/received_events","type":"Organization","site_admin":false},"repo":{"id":39556332,"name":"phovea_core","full_name":"phovea/phovea_core","owner":{"login":"phovea","id":21689003,"avatar_url":"https://avatars.githubusercontent.com/u/21689003?v=3","gravatar_id":"","url":"https://api.github.com/users/phovea","html_url":"https://github.com/phovea","followers_url":"https://api.github.com/users/phovea/followers","following_url":"https://api.github.com/users/phovea/following{/other_user}","gists_url":"https://api.github.com/users/phovea/gists{/gist_id}","starred_url":"https://api.github.com/users/phovea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phovea/subscriptions","organizations_url":"https://api.github.com/users/phovea/orgs","repos_url":"https://api.github.com/users/phovea/repos","events_url":"https://api.github.com/users/phovea/events{/privacy}","received_events_url":"https://api.github.com/users/phovea/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/phovea/phovea_core","description":"Phovea core includes the plugin registry, data definition (+ common types: tables, matrix, vector, stratification), ajax, selections","fork":false,"url":"https://api.github.com/repos/phovea/phovea_core","forks_url":"https://api.github.com/repos/phovea/phovea_core/forks","keys_url":"https://api.github.com/repos/phovea/phovea_core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phovea/phovea_core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phovea/phovea_core/teams","hooks_url":"https://api.github.com/repos/phovea/phovea_core/hooks","issue_events_url":"https://api.github.com/repos/phovea/phovea_core/issues/events{/number}","events_url":"https://api.github.com/repos/phovea/phovea_core/events","assignees_url":"https://api.github.com/repos/phovea/phovea_core/assignees{/user}","branches_url":"https://api.github.com/repos/phovea/phovea_core/branches{/branch}","tags_url":"https://api.github.com/repos/phovea/phovea_core/tags","blobs_url":"https://api.github.com/repos/phovea/phovea_core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phovea/phovea_core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phovea/phovea_core/git/refs{/sha}","trees_url":"https://api.github.com/repos/phovea/phovea_core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phovea/phovea_core/statuses/{sha}","languages_url":"https://api.github.com/repos/phovea/phovea_core/languages","stargazers_url":"https://api.github.com/repos/phovea/phovea_core/stargazers","contributors_url":"https://api.github.com/repos/phovea/phovea_core/contributors","subscribers_url":"https://api.github.com/repos/phovea/phovea_core/subscribers","subscription_url":"https://api.github.com/repos/phovea/phovea_core/subscription","commits_url":"https://api.github.com/repos/phovea/phovea_core/commits{/sha}","git_commits_url":"https://api.github.com/repos/phovea/phovea_core/git/commits{/sha}","comments_url":"https://api.github.com/repos/phovea/phovea_core/comments{/number}","issue_comment_url":"https://api.github.com/repos/phovea/phovea_core/issues/comments{/number}","contents_url":"https://api.github.com/repos/phovea/phovea_core/contents/{+path}","compare_url":"https://api.github.com/repos/phovea/phovea_core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phovea/phovea_core/merges","archive_url":"https://api.github.com/repos/phovea/phovea_core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phovea/phovea_core/downloads","issues_url":"https://api.github.com/repos/phovea/phovea_core/issues{/number}","pulls_url":"https://api.github.com/repos/phovea/phovea_core/pulls{/number}","milestones_url":"https://api.github.com/repos/phovea/phovea_core/milestones{/number}","notifications_url":"https://api.github.com/repos/phovea/phovea_core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phovea/phovea_core/labels{/name}","releases_url":"https://api.github.com/repos/phovea/phovea_core/releases{/id}","deployments_url":"https://api.github.com/repos/phovea/phovea_core/deployments","created_at":"2015-07-23T08:49:28Z","updated_at":"2016-11-06T09:27:39Z","pushed_at":"2016-11-19T21:36:08Z","git_url":"git://github.com/phovea/phovea_core.git","ssh_url":"git@github.com:phovea/phovea_core.git","clone_url":"https://github.com/phovea/phovea_core.git","svn_url":"https://github.com/phovea/phovea_core","homepage":"http://phovea.caleydo.org/","size":406,"stargazers_count":4,"watchers_count":4,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/phovea/phovea_core/pulls/15"},"html":{"href":"https://github.com/phovea/phovea_core/pull/15"},"issue":{"href":"https://api.github.com/repos/phovea/phovea_core/issues/15"},"comments":{"href":"https://api.github.com/repos/phovea/phovea_core/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/phovea/phovea_core/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/phovea/phovea_core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/phovea/phovea_core/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/phovea/phovea_core/statuses/49c65f222221e7cd2ffa2b1d2599ee152a8ed243"}}}}
{"actor":{"display_login":"mccalluc"}}