LeagueStats/server/app/Lib/Jax/JaxRequest.js

26 lines
546 B
JavaScript
Raw Normal View History

2019-08-24 14:56:55 +00:00
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)
2019-08-24 14:56:55 +00:00
}
}
}
module.exports = JaxRequest