forked from mustbebuilt/node-only-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapiCall.js
More file actions
26 lines (25 loc) · 648 Bytes
/
apiCall.js
File metadata and controls
26 lines (25 loc) · 648 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var http = require("http");
var options = {
hostname : "environment.data.gov.uk",
port : 443,
path :"flood-monitoring/id/floods",
method : "GET"
}
// var options = {
// hostname : "www.ywonline.co.uk",
// port : 80,
// path :"/web/newincid.nsf/incidentsjson",
// method : "GET"
// }
var req = http.request(options, function(res){
console.log(`Server ${res.statusCode}`);
var myData = ""; res.on("data", function(chunk){
console.log(chunk); myData+= chunk; })
res.on('end', function(){
console.info(myData);
})
})
req.on('error', function(err) {
// Handle error
console.dir(err);
});