From b8a2342de05421e1177fcd9abe85c9b12679ea58 Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Sun, 29 Sep 2019 12:50:54 -0600 Subject: [PATCH] Video 41 --- playground/6-raw-http.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 playground/6-raw-http.js diff --git a/playground/6-raw-http.js b/playground/6-raw-http.js new file mode 100644 index 0000000..3438a04 --- /dev/null +++ b/playground/6-raw-http.js @@ -0,0 +1,22 @@ +const https = require('https') +const url = 'https://api.darksky.net/forecast/0466bccb953c0b9daeb091a529da2c0d/40,-75?units=si' + +const request = https.request(url, (response) => { + let data = '' + + response.on('data', (chunk) => { + data = data + chunk.toString() + }) + + response.on('end', () => { + const body = JSON.parse(data) + console.log(body) + }) + +}) + +request.on('error', (error) => { + console.log('An error', error) +}) + +request.end()