startgg-helper-browser 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.js +20 -12
- package/package.json +6 -2
package/main.js
CHANGED
|
@@ -11,21 +11,29 @@ export async function loadQuery(url, maxTries = null){
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function requestStartGG(schema, variables, token){
|
|
15
|
-
|
|
16
|
-
method: 'POST',
|
|
17
|
-
headers: {
|
|
18
|
-
'Content-Type': 'application/json',
|
|
19
|
-
'accept'
|
|
20
|
-
'Authorization'
|
|
14
|
+
async function requestStartGG(schema, variables, token){
|
|
15
|
+
const response = await fetch('https://api.start.gg/gql/alpha', {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
headers: {
|
|
18
|
+
'Content-Type': 'application/json',
|
|
19
|
+
'accept': 'application/json',
|
|
20
|
+
'Authorization': token
|
|
21
21
|
},
|
|
22
22
|
body: JSON.stringify({
|
|
23
23
|
'query': schema,
|
|
24
|
-
'variables'
|
|
25
|
-
}),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
'variables': variables
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
const json = await response.json();
|
|
28
|
+
if (!json){
|
|
29
|
+
throw "Empty response"
|
|
30
|
+
}
|
|
31
|
+
if (!json.success){
|
|
32
|
+
throw new Error("GraphQL Error (code" + response.status + ")" + {response, request: {
|
|
33
|
+
schema, variables
|
|
34
|
+
}})
|
|
35
|
+
}
|
|
36
|
+
return json.data;
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
export class SGGHelperClient {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "startgg-helper-browser",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A set of functions and classes useful to communicate with the start.gg API from a web app",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,5 +24,9 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"startgg-helper": "^1.0.2"
|
|
26
26
|
},
|
|
27
|
-
"type": "module"
|
|
27
|
+
"type": "module",
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"webpack": "^5.94.0",
|
|
30
|
+
"webpack-cli": "^5.1.4"
|
|
31
|
+
}
|
|
28
32
|
}
|