@timmsy/riftjs
Version:
A lightweight Node.js wrapper for the Riot Games API, providing easy access to League of Legends game data.
29 lines (27 loc) • 762 B
JavaScript
const axios = require('axios');
module.exports = (baseURL) => ({
/**
* Get all champion data.
* @returns {Promise<object>} Champion data.
*/
async getChampions() {
try {
const response = await axios.get(`${baseURL}/champion.json`);
return response.data;
} catch (error) {
throw new Error(`DataDragon error: ${error.message}`);
}
},
/**
* Get all item data.
* @returns {Promise<object>} Item data.
*/
async getItems() {
try {
const response = await axios.get(`${baseURL}/item.json`);
return response.data;
} catch (error) {
throw new Error(`DataDragon error: ${error.message}`);
}
},
});