LeagueStats/server/app/Lib/Jax/JaxRequest.js
2019-09-11 09:06:21 +02:00

25 lines
546 B
JavaScript

class JaxRequest {
constructor(endpoint, limiter, region) {
this.endpoint = endpoint
this.limiter = limiter
this.region = region
}
async execute() {
try {
const resp = await this.limiter.executing({
url: `https://${this.region}.api.riotgames.com/lol/${this.endpoint}`,
token: process.env.API_KEY,
resolveWithFullResponse: false
})
return JSON.parse(resp)
} catch ({ statusCode, ...rest }) {
console.log('error: ' + statusCode)
}
}
}
module.exports = JaxRequest