Skip to content

Commit 624e157

Browse files
committed
Add league battles!
1 parent 7401416 commit 624e157

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

index.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,38 @@
11
'use strict';
22

3+
var axios = require('axios');
4+
35
/**
46
* Gets the current battles
5-
* @param {string} mode
67
* @return {object}
78
*/
8-
module.exports.getCurrentStages = function(mode) {
9+
module.exports.getCurrentStages = function() {
10+
var leagueDataMode;
11+
var leagueDataStageA;
12+
var leagueDataStageB;
13+
var leagueDataStart;
14+
var leagueDataEnd;
15+
axios.get('https://splatoon2.ink/data/schedules.json')
16+
.then(function (res) {
17+
var leagueDataMode = res.data.league[0].rule.name;
18+
var leagueDataStageA = res.data.league[0].stage_a.name;
19+
var leagueDataStageB = res.data.league[0].stage_b.name;
20+
var leagueDataStart = res.data.league[0].start_time;
21+
var leagueDataEnd = res.data.league[0].end_time;
22+
})
23+
.catch(function (error) {
24+
console.log(error);
25+
});
26+
927
var data = {
10-
apiVersion: "0.1.1"
28+
apiVersion: "0.1.1",
29+
league: {
30+
mode: leagueDataMode,
31+
stageA: leagueDataStageA,
32+
stageB: leagueDataStageB,
33+
start: leagueDataStart,
34+
end: leagueDataEnd
35+
}
1136
};
1237
return data;
1338
};

test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var expect = require('chai').expect;
44
var client = require('../index');
55

6-
describe('#numFormatter', function() {
6+
describe('#api', function() {
77
it('should give API version', function() {
88
var data = client.getCurrentStages();
99
expect(data.apiVersion).to.equal('0.1.1');

0 commit comments

Comments
 (0)