Skip to content

Instantly share code, notes, and snippets.

@corlaez
Last active January 5, 2019 00:33
Show Gist options
  • Save corlaez/8495917478b2e05e29fecc77212b7eb2 to your computer and use it in GitHub Desktop.
Save corlaez/8495917478b2e05e29fecc77212b7eb2 to your computer and use it in GitHub Desktop.

does this works?

it does
#!/usr/bin/env node
var https = require('https');
var options = {
host: 'api.coindesk.com',
port: 443,
path: '/v1/bpi/currentprice.json',
method: 'GET'
};
var req = https.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function (data) {
console.log("Sabías que hoy 1 bitcoin equivale a $" + JSON.parse(data).bpi.USD.rate + "?");
console.log("Eso es todo, mucho gusto!");
});
});
req.on('error', function(e) {
console.log("Iba a decirte el valor actual del bitcoin pero hay un problema con el internet.");
console.log("Gracias por pasar por aquí. Eso es todo!");
});
// write data to request body
req.write('data\n');
req.write('data\n');
req.end();
console.log("Hola, soy Armando Córdova!")
console.log("Para saber más de mi ve a: https://lrn2prgrm.com/");
{
"name": "npx-gist",
"version": "0.0.1",
"bin": "./index.js"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment