nodeschool / discussions

:school::speech_balloon: need help with nodeschool? or just wanna ask a question? open an issue on this repo!
488 stars 107 forks source link

Juggling Async --code not working #2131

Closed rustycell closed 6 years ago

rustycell commented 7 years ago

Notes

i am getting no output for chapter "Juggling Async" in C9. i cannot visualize what is going wrong here, your help is highly appreciated..

below is the problem statement. "This problem is the same as the previous problem (HTTP COLLECT) in that
you need to use http.get(). However, this time you will be provided with
three URLs as the first three command-line arguments.

You must collect the complete content provided to you by each of the URLs
and print it to the console (stdout). You don't need to print out the
length, just the data as a String; one line per URL. The catch is that you
must print them out in the same order as the URLs are provided to you as
command-line arguments.
"

If you have a problem with an error message:

Error output

1.  ACTUAL:    ""
1.  EXPECTED:  "Gutful of porky and as dry as a yabber. Trent from punchy cooee heaps she'll be right ute. She'll be right ropeable and shazza got us some rage on. "

2.  ACTUAL:    ""
2.  EXPECTED:  "As dry as a snag mate you little ripper fair go. She'll be right gobful also she'll be right schooner. As busy as a clacker heaps gutful of dag. Get a dog up ya ugg bloody trent from punchy bush bash. "

3.  ACTUAL:    "Gutful of porky and as dry as a yabber. Trent from punchy cooee heaps she'll be right ute. She'll be right ropeable and shazza got us some rage on. "
3.  EXPECTED:  "Shazza got us some not my bowl of rice my as cunning as a bities. Stands out like a grog bloody we're going cactus mate. Come a cane toad and as stands out like greenie. Watch out for the parma and as dry as a chuck a sickie. "

4.  ACTUAL:    ""
4.  EXPECTED:  ""

My Code

// var http = require('http'); var bl = require('bl');

http.get(process.argv[2], function (response){ http.get(process.argv[3], function (response1){ http.get(process.argv[4], function(response2){ response.pipe(bl(function(err, data2) { response.pipe(bl(function(err, data1){ response.pipe(bl(function(err, data){ console.log(data.toString()) console.log(data1.toString()) console.log(data2.toString()) }))

            }))
        }))

    })
})

}).on('error', function(e){ console.log(e.message);

});

francesmcmullin commented 7 years ago

One handy technique when debugging these problems is to use run instead of verify so that you can see only your program output and any errors it produces. Here's some example output I got from learnyounode run prog.js with your code:


Lets throw a brizzie to stands out like a mate. As cross as a vee dub my shazza got us some rip snorter. As stands out like rego where he's got a massive mokkies. He hasn't got a boil-over when trent from punchy divvy van. We're going uluru bloody as busy as a rego.

So, your code actually is outputting something, and in fact if we look more closely to the output you provided, we can see that 3. ACTUAL: has some content. Your program is providing output, but only in 1 out of 3 cases. Reading your code again, can you spot the reason why?

stale[bot] commented 7 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.