{"action":"created","issue":{"url":"https://api.github.com/repos/nodeschool/discussions/issues/1152","labels_url":"https://api.github.com/repos/nodeschool/discussions/issues/1152/labels{/name}","comments_url":"https://api.github.com/repos/nodeschool/discussions/issues/1152/comments","events_url":"https://api.github.com/repos/nodeschool/discussions/issues/1152/events","html_url":"https://github.com/nodeschool/discussions/issues/1152","id":76967851,"number":1152,"title":"Exercice 8: http collect","user":{"login":"Djabx","id":69534,"avatar_url":"https://avatars.githubusercontent.com/u/69534?v=3","gravatar_id":"","url":"https://api.github.com/users/Djabx","html_url":"https://github.com/Djabx","followers_url":"https://api.github.com/users/Djabx/followers","following_url":"https://api.github.com/users/Djabx/following{/other_user}","gists_url":"https://api.github.com/users/Djabx/gists{/gist_id}","starred_url":"https://api.github.com/users/Djabx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Djabx/subscriptions","organizations_url":"https://api.github.com/users/Djabx/orgs","repos_url":"https://api.github.com/users/Djabx/repos","events_url":"https://api.github.com/users/Djabx/events{/privacy}","received_events_url":"https://api.github.com/users/Djabx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-16T07:11:10Z","updated_at":"2015-05-17T20:40:35Z","closed_at":null,"body":"For the excercice 8 I wrote this:\r\n\r\n``` javascript\r\n\r\nvar http = require('http')\r\n\r\nhttp.get(process.argv[2],\r\n  function(response) {\r\n    response.setEncoding('utf8')\r\n    var result = [];\r\n    response.on(\"data\", result.push)\r\n    response.on(\"error\", console.error)\r\n    response.on(\"end\",\r\n      function () {\r\n        var s = result.join('')\r\n        console.log(s.length)\r\n        console.log(s)\r\n      }\r\n    )\r\n  }\r\n)\r\n```\r\n\r\nBut it does not work, the `result` is always empty.\r\nCan somebody explain why to me ? \r\n\r\nBTW this solution work well :\r\n```javascript\r\nvar http = require('http')\r\n\r\nhttp.get(process.argv[2],\r\n  function(response) {\r\n    response.setEncoding('utf8')\r\n    var result = [];\r\n    response.on(\"data\", function (data){result.push(data)})\r\n    response.on(\"error\", console.error)\r\n    response.on(\"end\",\r\n      function () {\r\n        var s = result.join('')\r\n        console.log(s.length)\r\n        console.log(s)\r\n      }\r\n    )\r\n  }\r\n)\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/nodeschool/discussions/issues/comments/102854297","html_url":"https://github.com/nodeschool/discussions/issues/1152#issuecomment-102854297","issue_url":"https://api.github.com/repos/nodeschool/discussions/issues/1152","id":102854297,"user":{"login":"Djabx","id":69534,"avatar_url":"https://avatars.githubusercontent.com/u/69534?v=3","gravatar_id":"","url":"https://api.github.com/users/Djabx","html_url":"https://github.com/Djabx","followers_url":"https://api.github.com/users/Djabx/followers","following_url":"https://api.github.com/users/Djabx/following{/other_user}","gists_url":"https://api.github.com/users/Djabx/gists{/gist_id}","starred_url":"https://api.github.com/users/Djabx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Djabx/subscriptions","organizations_url":"https://api.github.com/users/Djabx/orgs","repos_url":"https://api.github.com/users/Djabx/repos","events_url":"https://api.github.com/users/Djabx/events{/privacy}","received_events_url":"https://api.github.com/users/Djabx/received_events","type":"User","site_admin":false},"created_at":"2015-05-17T20:40:35Z","updated_at":"2015-05-17T20:40:35Z","body":"Thank you !\r\n\r\nI'm going to read the MDN article rigth away !\r\n\r\nI'm coming from the python world where we do not have this kind of problems ;)\r\n "}}