-
Notifications
You must be signed in to change notification settings - Fork 0
/
requests.js
52 lines (32 loc) · 1.36 KB
/
requests.js
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
const test = require("./testingMethods.js");
const Yuko = require("./Yuko.js");
const fetch = require("node-fetch");
module.exports = {
twitch: {
getStream: async (url) => {
let urlPieces = url.split('/');
let username = urlPieces[urlPieces.length - 1];
let response = await fetch(`https://api.twitch.tv/helix/streams?user_login=${username}`
, {method: 'GET', headers: {"Client-ID": Yuko.settings.twitchId}} );
let streamInfo = await response.json();
return streamInfo;
},
isTwitch: (url) => {
return url.indexOf('www.twitch.tv/') > -1 ? true: false;
},
getGame: async (gameId) => {
let response = await fetch(`https://api.twitch.tv/helix/games?id=${gameId}`
, {method: 'GET', headers: {"Client-ID": Yuko.settings.twitchId}} );
let gameInfo = await response.json();
return gameInfo;
},
getUser: async (url) => {
let urlPieces = url.split('/');
let username = urlPieces[urlPieces.length - 1];
let response = await fetch(`https://api.twitch.tv/helix/users?login=${username}`
, {method: 'GET', headers: {"Client-ID": Yuko.settings.twitchId}} );
let userInfo = await response.json();
return userInfo;
}
}
}