-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from jakejrichards/RefactorPromise
Refactor: Move to promise style api calls and use axios over request
- Loading branch information
Showing
4 changed files
with
94 additions
and
81 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,49 @@ | ||
const { getProfile, getRecentMatches, getRecentSummary, getLeaderboards } = require('../index'); // require('cod-api'); | ||
const { getLeaderboards, getProfile, getRecentMatches, getRecentSummary } = require('../index'); // require('cod-api'); | ||
|
||
var options = { | ||
title: "wwii", // bo3, iw, wwii | ||
platform: "psn", // psn, xbl, steam | ||
username: "Consisttt", // username | ||
days: 1, // amount of days (required for recent matches & summary), | ||
type: "core", // core, hc, arena | ||
time: "monthly", // alltime, monthly, weekly | ||
mode: "war" // career, war (Team Deathmatch), dm (Free-For-All), conf (Kill Confirmed), ctf (Capture The Flag), sd (Search & Destroy), dom (Domination), ball (Gridiron), hp (Hardpoint), 1v1, raid (War) | ||
}; | ||
const title = "wwii"; // bo3, iw, wwii | ||
const platform = "psn"; // psn, xbl, steam | ||
const username = "Consisttt"; // username | ||
const days = 7; // amount of days (required for recent matches & summary), | ||
const type = "core"; // core, hc, arena | ||
const time = "monthly"; // alltime, monthly, weekly | ||
const mode = "war"; // career, war (Team Deathmatch), dm (Free-For-All), conf (Kill Confirmed), ctf (Capture The Flag), sd (Search & Destroy), dom (Domination), ball (Gridiron), hp (Hardpoint), 1v1, raid (War) | ||
|
||
getProfile(options, profile => { | ||
console.log(profile); | ||
}); | ||
getProfile({ title, platform, username }) | ||
.then(profile => { | ||
// Do something with the profile object | ||
console.log(profile); | ||
}) | ||
.catch(err => { | ||
// Do something with this error | ||
console.log(err); | ||
}); | ||
|
||
getRecentMatches(options, matches => { | ||
console.log(matches); | ||
}); | ||
|
||
getRecentSummary(options, summary => { | ||
console.log(summary); | ||
}); | ||
|
||
getLeaderboards(options, leaderboards => { | ||
console.log(leaderboards); | ||
}); | ||
getRecentMatches({ title, platform, username, days }) | ||
.then(profile => { | ||
// Do something with the recent matches object | ||
console.log(profile); | ||
}) | ||
.catch(err => { | ||
// Do something with this error | ||
console.log(err); | ||
}); | ||
|
||
getRecentSummary({ title, platform, username, days }) | ||
.then(profile => { | ||
// Do something with the recent summary object | ||
console.log(profile); | ||
}) | ||
.catch(err => { | ||
// Do something with this error | ||
console.log(err); | ||
}); | ||
|
||
getLeaderboards({ title, platform, time, type, mode, username }) | ||
.then(profile => { | ||
// Do something with the leaderboards object | ||
console.log(profile); | ||
}) | ||
.catch(err => { | ||
// Do something with this error | ||
console.log(err); | ||
}); |
This file contains 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
This file contains 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