Using champions alias instead of id in urls
All checks were successful
pipeline / build-and-push-images (push) Successful in 25s
All checks were successful
pipeline / build-and-push-images (push) Successful in 25s
This commit is contained in:
@@ -12,19 +12,19 @@ async function fetchLatestPatch(client) {
|
||||
const latestPatch = await patches.find().limit(1).sort({date:-1}).next()
|
||||
return latestPatch.patch
|
||||
}
|
||||
async function championInfos(client, patch, championId) {
|
||||
async function championInfos(client, patch, championAlias) {
|
||||
const database = client.db("champions");
|
||||
const collection = database.collection(patch);
|
||||
const query = { id:Number(championId) };
|
||||
const query = { alias:championAlias };
|
||||
const championInfo = await collection.findOne(query);
|
||||
return championInfo
|
||||
}
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const championId = getRouterParam(event, "id")
|
||||
const championAlias = getRouterParam(event, "alias").toLowerCase()
|
||||
const client = await connectToDatabase();
|
||||
const latestPatch = await fetchLatestPatch(client);
|
||||
const data = await championInfos(client, latestPatch, championId);
|
||||
const data = await championInfos(client, latestPatch, championAlias);
|
||||
await client.close()
|
||||
return data
|
||||
})
|
||||
Reference in New Issue
Block a user