I am new to node and I am going through nodeschool.io interactive learnyounode tutorials and I have problem with http-collect problem.
Firstly, the actual solution that uses the third-party Buffered List package to solve the problem does not work when I run the learnyounode verify command. I'm not even sure how to test this side of the learnyounode test. How can I do it? Am I assuming some kind of node service?
Secondly, since I really do not understand this, I would really like to try to implement it without a third-party package, but I do not know where to start. I am not looking for a solution for me, but I really appreciate what is needed in the right direction, be it an online tutorial or a specific method in the node documentation that can help.
For reference, this is learnyounode solution which I am not able to
var http = require('http') var bl = require('bl') http.get(process.argv[2], function (request) { request.pipe(bl(function (err, data) { if (err) return console.error(data) data = data.toString() console.log(data.length) console.log(data) })) })
Exit learnyounode verify http-collect
Verifying "HTTP COLLECT"... ACTUAL: "" EXPECTED: "123" ACTUAL: null EXPECTED: "Flat out like a swag no worries as dry as a big smoke. Lets throw a fruit loop how as stands out like not my bowl of rice. " ACTUAL: null EXPECTED: "" # FAIL Your solution to HTTP COLLECT didn't match the expected output. Try again!
Update: possible proxy problem ...
Further update: not a problem with the proxy server, but leaving this section here in case the information is useful to someone else
So, I believe that I understood the problem, but still did not understand the solution. I think this is a proxy problem since I am doing this on a production network. I came to this conclusion because I had the same error with the following
http.get({path:'http://www.google.com/index.html'}, function(res) { console.log("Got response: " + res.statusCode); }).on('error', function(e) { console.log("Got error: " + e.message); });
as soon as I changed the fragment above to the next one, where our company’s proxy server is http://http.proxy.somewhere.com:1234 , I no longer receive an error for this fragment, unfortunately, this is not enough to check learnyounode.
http.get({ host: 'http.proxy.somewhere.com', path:'http://www.google.com/index.html', port: 1234}, function(res) { console.log("Got response: " + res.statusCode); }).on('error', function(e) { console.log("Got error: " + e.message); });
Buffered List Solution
The problem was that the bl module was not installed locally, I installed it globally initially and it seems to be causing the problem, I don’t know why, if anyone can explain why this could be the problem, please