{"action":"created","issue":{"url":"https://api.github.com/repos/evantahler/actionhero/issues/772","repository_url":"https://api.github.com/repos/evantahler/actionhero","labels_url":"https://api.github.com/repos/evantahler/actionhero/issues/772/labels{/name}","comments_url":"https://api.github.com/repos/evantahler/actionhero/issues/772/comments","events_url":"https://api.github.com/repos/evantahler/actionhero/issues/772/events","html_url":"https://github.com/evantahler/actionhero/issues/772","id":134660386,"number":772,"title":"Using the `ActionheroClient.prototype.actionWeb` method","user":{"login":"running-coder","id":7377382,"avatar_url":"https://avatars.githubusercontent.com/u/7377382?v=3","gravatar_id":"","url":"https://api.github.com/users/running-coder","html_url":"https://github.com/running-coder","followers_url":"https://api.github.com/users/running-coder/followers","following_url":"https://api.github.com/users/running-coder/following{/other_user}","gists_url":"https://api.github.com/users/running-coder/gists{/gist_id}","starred_url":"https://api.github.com/users/running-coder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/running-coder/subscriptions","organizations_url":"https://api.github.com/users/running-coder/orgs","repos_url":"https://api.github.com/users/running-coder/repos","events_url":"https://api.github.com/users/running-coder/events{/privacy}","received_events_url":"https://api.github.com/users/running-coder/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/evantahler/actionhero/labels/bug","name":"bug","color":"e10c02"},{"url":"https://api.github.com/repos/evantahler/actionhero/labels/nice-to-have","name":"nice-to-have","color":"02d7e1"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-18T18:43:50Z","updated_at":"2016-02-18T19:51:44Z","closed_at":null,"body":"Hey, my case is pretty simple, at some point in my application the user is not connected with the WS so the condition falls back inside the `actionWeb` method. I was playing around trying to understand how change the request type to `GET` and found out the `httpMethod` option.\r\n\r\n[params.httpMethod](https://github.com/evantahler/actionhero/blob/v13.0.2/client/actionheroClient.js#L194)\r\n\r\nThe `xmlhttp.send(JSON.stringify(params));` works for a `POST` request but does not work with a `GET` unless I'm missing something.\r\n\r\nMy code looks like:\r\n``` javascript\r\nclient.action(\"gameHistoryViewAll\", {httpMethod: 'GET', gameId: 42}, function (apiResponse) {\r\n    console.log(apiResponse)\r\n});\r\n```\r\n\r\n![2016-02-18_1341](https://cloud.githubusercontent.com/assets/7377382/13154133/7d076220-d645-11e5-9e35-82aefeb6695b.png)\r\n\r\n\r\n![2016-02-18_1342](https://cloud.githubusercontent.com/assets/7377382/13154137/8084fbec-d645-11e5-9cc4-dbdbec89c8de.png)\r\n\r\nAs you can see it's missing the `gameId` parameter inside the query string\r\n"},"comment":{"url":"https://api.github.com/repos/evantahler/actionhero/issues/comments/185888652","html_url":"https://github.com/evantahler/actionhero/issues/772#issuecomment-185888652","issue_url":"https://api.github.com/repos/evantahler/actionhero/issues/772","id":185888652,"user":{"login":"running-coder","id":7377382,"avatar_url":"https://avatars.githubusercontent.com/u/7377382?v=3","gravatar_id":"","url":"https://api.github.com/users/running-coder","html_url":"https://github.com/running-coder","followers_url":"https://api.github.com/users/running-coder/followers","following_url":"https://api.github.com/users/running-coder/following{/other_user}","gists_url":"https://api.github.com/users/running-coder/gists{/gist_id}","starred_url":"https://api.github.com/users/running-coder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/running-coder/subscriptions","organizations_url":"https://api.github.com/users/running-coder/orgs","repos_url":"https://api.github.com/users/running-coder/repos","events_url":"https://api.github.com/users/running-coder/events{/privacy}","received_events_url":"https://api.github.com/users/running-coder/received_events","type":"User","site_admin":false},"created_at":"2016-02-18T19:51:44Z","updated_at":"2016-02-18T19:51:44Z","body":"I've slightly modified the method to include the `GET` case. The `toUpperCase` is not mandatory but I have the habit of always doing strict comparisons\r\n\r\n``` javascript\r\nActionheroClient.prototype.actionWeb = function(params, callback) {\r\n  var xmlhttp = new XMLHttpRequest();\r\n  xmlhttp.onreadystatechange = function () {\r\n    var response;\r\n    if(xmlhttp.readyState === 4) {\r\n      if(xmlhttp.status === 200) {\r\n        response = JSON.parse(xmlhttp.responseText);\r\n      }else{\r\n        try{\r\n          response = JSON.parse(xmlhttp.responseText);\r\n        }catch(e){\r\n          response = { error: {statusText: xmlhttp.statusText, responseText: xmlhttp.responseText} };\r\n        }\r\n      }\r\n      callback(response);\r\n    }\r\n  };\r\n\r\n  var method = (params.httpMethod || 'POST').toUpperCase();\r\n  var url = this.options.url + this.options.apiPath + '?action=' + params.action;\r\n\r\n  if (method === 'GET') {\r\n    for (var param in params) {\r\n      if (~['action', 'httpMethod'].indexOf(param)) continue;\r\n      url += '&' + param + '=' + params[param];\r\n    }\r\n  }\r\n\r\n  xmlhttp.open(method, url, true);\r\n  xmlhttp.setRequestHeader('Content-Type', 'application/json');\r\n  xmlhttp.send(JSON.stringify(params));\r\n}\r\n```"}}