Skip to content

Commit

Permalink
Update main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
haxgun authored Sep 15, 2024
1 parent 485ba91 commit 6a6375a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -703,18 +703,19 @@ copyButton.onclick = function () {
};

async function main() {
const hdevApiKey= document.getElementById("hdevApi").value;
const inputNicknameWithTag = document.getElementById("nickname_with_tag");
const nicknameWithTag = inputNicknameWithTag.value;
const [nickname, tag] = nicknameWithTag.split("#");

const check = await checkData(nickname, tag);
const check = await checkData(nickname, tag, hdevApiKey);

if (check) {
await insertinData();
}
}

async function checkData(nickname, tag) {
async function checkData(nickname, tag, hdevApiKey) {
try {
const response = await fetch(`${apiUrl}/v1/account/${nickname}/${tag}?api_key=${hdevApiKey}`);
const data = await response.json();
Expand Down Expand Up @@ -813,8 +814,8 @@ async function formationUserData(nickname, tag) {
ranking_in_tier,
mmr_change_to_last_game,
elo,
] = await getPlayerInformation(region, puuid);
const leaderboard = await getLeaderboard(region, puuid);
] = await getPlayerInformation(region, puuid, hdevApiKey);

Check failure on line 817 in src/js/main.js

View workflow job for this annotation

GitHub Actions / ESLint

src/js/main.js#L817

'hdevApiKey' is not defined (no-undef)
const leaderboard = await getLeaderboard(region, puuid, hdevApiKey);

Check failure on line 818 in src/js/main.js

View workflow job for this annotation

GitHub Actions / ESLint

src/js/main.js#L818

'hdevApiKey' is not defined (no-undef)

return {
nickname: nickname,
Expand All @@ -830,22 +831,22 @@ async function formationUserData(nickname, tag) {
};
}

async function getPuuidWithRegion(nickname, tag) {
async function getPuuidWithRegion(nickname, tag, hdevApiKey) {
const response = await fetch(`${apiUrl}/v1/account/${nickname}/${tag}?api_key=${hdevApiKey}`);
const data = await response.json();
return [data.data.puuid, data.data.region];
}

async function getLeaderboard(region, puuid) {
async function getLeaderboard(region, puuid, hdevApiKey) {
const response = await fetch(
`${apiUrl}/v1/leaderboard/${region}?puuid=${puuid}`,
`${apiUrl}/v1/leaderboard/${region}?puuid=${puuid}?api_key=${hdevApiKey}`,
);
const data = await response.json();
return data.status === 404 ? " " : data.data[0].leaderboardRank;
}

async function getPlayerInformation(region, puuid) {
const response = await fetch(`${apiUrl}/v1/by-puuid/mmr/${region}/${puuid}`);
async function getPlayerInformation(region, puuid, hdevApiKey) {
const response = await fetch(`${apiUrl}/v1/by-puuid/mmr/${region}/${puuid}?api_key=${hdevApiKey}`);
const data = await response.json();
return [
data.data.currenttier,
Expand Down

0 comments on commit 6a6375a

Please sign in to comment.