We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello, guys. I made a frankestein code to resolve this. (And it's bad but if you try various times it works)
var http = require("http"); var url = [process.argv[2], process.argv[3], process.argv[4]]; var responses = []; var completed_req = 0; for(var i in url){ http.get(url[i], function(response){ var content = ""; //if(completed_req== url.length){ response.setEncoding("utf-8"); response.on("data", function(data){ content += data; }) response.on("error", console.error); response.on("end", function(end){ console.log(content); }); }) };
And the final solution was:
var http = require("http"); var bl = require("bl"); var results = []; var count = 0; function printResults(){ for(var i = 0; i < 3; i++) console.log(results[i]); } function httpGet(index){ http.get(process.argv[2 + index], function(response){ response.pipe(bl(function(err, data){ if (err) return console.error(err); results[index] = data.toString(); count++; if(count == 3) printResults() })) }) } for(var i = 0; i < 3; i++) httpGet(i);
And! Surprise it didn't work when I copy it to my file. (I use Spanish language)
I hope it can be fixed (and get the right answer).
EDIT: For some what reason I skipped step 8, then BL now makes sense. I'm gonna close this to fell less stupid.
EDIT 2: After make it works on step 8 without using BL now I need to know how resolve without bl on step 9.
Step 8 results:
var http = require("http"); var url = process.argv[2]; http.get(url, function(response){ var result = ""; response.setEncoding("utf-8"); response.on("data", function(data){ result += data; }); response.on("error", console.error); response.on("end", function(end){ console.log(result.length); console.log(result); }); });
Official result:
var http = require("http"); var bl = require("bl"); http.get(process.argv[2], function(response){ response.pipe(bl(function (err,data){ if (err) return console.error(err); data = data.toString(); console.log(data.length); console.log(data); })) })
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello, guys. I made a frankestein code to resolve this. (And it's bad but if you try various times it works)
And the final solution was:
And! Surprise it didn't work when I copy it to my file. (I use Spanish language)
I hope it can be fixed (and get the right answer).
EDIT: For some what reason I skipped step 8, then BL now makes sense. I'm gonna close this to fell less stupid.
EDIT 2: After make it works on step 8 without using BL now I need to know how resolve without bl on step 9.
Step 8 results:
Official result:
The text was updated successfully, but these errors were encountered: