-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (20 loc) · 679 Bytes
/
index.js
File metadata and controls
25 lines (20 loc) · 679 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
#!/usr/bin/env node
'use strict';
const Table = require('cli-table');
const chalk = require('chalk');
const request = require('request');
const Game = require('./components/game');
const table = new Table({
head: [chalk.white('teams'), chalk.white('time'), chalk.white('score')],
});
request('http://data.nba.com/data/5s/v2015/json/mobile_teams/nba/2016/scores/00_todays_scores.json', (error, response, body) => {
const data = JSON.parse(body).gs.g;
const games = [];
data.forEach((item) => {
games.push(new Game(item));
});
games.forEach((game) => {
table.push([game.getTeams(), game.time, game.getScores()]);
});
console.log(table.toString());
});