1var http = require('http');
2
3var options = {
4 host: 'google.com',
5 path: '/'
6}
7var request = http.request(options, function (res) {
8 var data = '';
9 res.on('data', function (chunk) {
10 data += chunk;
11 });
12 res.on('end', function () {
13 console.log(data);
14
15 });
16});
17request.on('error', function (e) {
18 console.log(e.message);
19});
20request.end();
1const fetch = require('node-fetch');
2
3app.get('/', function (req, res) {
4 var url = 'https://api.darksky.net/forecast/<API KEY>/37.8267,-122.4233';
5
6 fetch(url)
7 .then(res => res.json())
8 .then(data => {
9 res.send({ data });
10 })
11 .catch(err => {
12 res.send(err);
13 });
14});