-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.js
More file actions
75 lines (67 loc) · 1.58 KB
/
Copy pathclient.js
File metadata and controls
75 lines (67 loc) · 1.58 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const fs = require('fs');
var request = require('request');
function writeToJS(data, dir, name){
if (!fs.existsSync(dir)){
fs.mkdirSync(dir);
}
fs.writeFile(`${dir}/${name}`, data, (err) => {
// Throw Error in Case of issues.
if (err) throw err;
});
};
var headers = {
'Content-Type': 'application/json'
};
let Int = 0;
// Sample of Queries
let queryobject = {
Gamertag: String,
Xp: Int,
SpartanRank: Int,
HighestCsrAttained: {
Tier: Int,
DesignationId: Int,
Csr: Int,
PercentToNextTier: Int,
Rank: Int
},
Stats: {
TotalKills: Int,
TotalHeadshots: Int,
TotalMeleeKills: Int,
TotalAssassinations: Int,
TotalGroundPoundKills: Int,
TotalShoulderBashKills: Int,
TotalPowerWeaponKills: Int,
TotalDeaths: Int,
TotalAssists: Int,
TotalGamesCompleted: Int,
TotalGamesWon: Int,
TotalGamesLost: Int,
TotalGamesTied: Int,
TotalGrenadeKills: Int,
TotalSpartanKills: Int,
},
TotalTimePlayed: String
}
var dataString = {
"query":
`{
Gamertag,
HighestCsrAttained {Csr, Rank},
Stats { TotalKills, TotalDeaths}
}
`};
var options = {
url: 'http://localhost:4000/graphql',
method: 'POST',
headers: headers,
body: JSON.stringify(dataString)
};
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
writeToJS(body, "response", `getPlayer.json`)
}
}
request(options, callback);