Video 41
This commit is contained in:
parent
5ffdfbbb98
commit
b8a2342de0
22
playground/6-raw-http.js
Normal file
22
playground/6-raw-http.js
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user