Created
June 20, 2014 01:58
-
-
Save tiomoreno/817b36a5b4ef0e0b4fc5 to your computer and use it in GitHub Desktop.
Um hack simples para pegar uma parcial com os jogos da copa em Node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var http = require('http'); | |
| http.get("http://worldcup.sfg.io/matches", function(response) { | |
| var body = ''; | |
| response.on('data', function(chunk) { | |
| body += chunk; | |
| }); | |
| response.on('end', function() { | |
| var matches = JSON.parse(body); | |
| matches.forEach(function (jogo) { | |
| if (jogo.status === 'completed') { | |
| console.log(jogo.home_team.country, jogo.home_team.goals, 'x', | |
| jogo.away_team.country, jogo.away_team.goals); | |
| } | |
| }); | |
| }); | |
| }).on('error', function(e) { | |
| console.log("Got error: " + e.message); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment