class LeagueAPI { constructor() { this.key = process.env.lolAPIKey || 'RGAPI-fc17a511-f587-495b-ac01-80716870d46b'; } async verifyUserName(nick, tag) { var options = { method: "GET", mode: "cors", headers: { "Origin": "https://developer.riotgames.com", "X-Riot-Token": this.key } } var res = await fetch(`https://europe.api.riotgames.com/riot/account/v1/accounts/by-riot-id/${nick}/${tag}`, options) .then(handleRes) .then(handleData) .catch(handleErrors) function handleRes(response) { return response.text() } function handleErrors(error) { return error; } function handleData(data) { data = JSON.parse(data); return { name:data.gameName, puuid:data.puuid } } return res.name?res:null; } }module.exports.LeagueAPI = LeagueAPI