Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
var http = require('http');
getData(process.argv[2], function onGet1(){
    getData(process.argv[3], function onGet2(){
        getData(process.argv[4]);
    };
});
function getData(url, callback) {
    http.get(url, function onGetData(res) {
        var statusCode = res.statusCode;
        var error;
        if(statusCode > 300){
            error = new Error('Request Failed.\n Status Code: ' + statusCode);
        }
        if (error) {
            console.log(error.message);
            res.resume();
            return;
        }
        var data = "";
        res.on('data', function onData(chunk) {
            data += chunk;
        });
        res.on('end', function onEnd() {
            console.log(data);
            if(callback){
                callback(); 
            }
        });
    }).on('error', function onError(e) {
      console.log('Error get data :' + e);
    });
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers