Skip to content

Commit

Permalink
added servi api example
Browse files Browse the repository at this point in the history
  • Loading branch information
robynitp committed Mar 10, 2015
1 parent aa259f3 commit 35f2b10
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions week6/13-servi_get_api/servi_http_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var servi = require('servi');
var app = new servi(true);
var http = require('http');
var url = "http://api.openweathermap.org/data/2.5/weather?q=NewYork,USA";
http.get(url, function(res) {
var data = "";
res.on('data', function (chunk) {
data += chunk;
});
res.on("end", function() {
console.log(data); // <-- this is the JSON
// do stuff with the JSON data here
});
}).on("error", function(e) {
console.log("Got error: " + e.message);
});

0 comments on commit 35f2b10

Please sign in to comment.