Skip to content

Commit

Permalink
better error handling for the follow goal
Browse files Browse the repository at this point in the history
  • Loading branch information
ThinLiquid committed Sep 7, 2024
1 parent b09515a commit 523b955
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions root.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,28 @@ <h4 style="margin: 0;">&copy; 2023-2024 ThinLiquid</h4>
</footer>
<script type="module">
const info = await fetch('https://nekoweb.org/api/site/info/thnlqd', {
cache: 'no-cache'
});
const data = await info.json();

const opp = async (username) => {
const info = await fetch('https://nekoweb.org/api/site/info/' + username, {
cache: 'no-cache'
});
cache: 'no-cache',
mode: 'no-cors'
}).catch(() => null);
if (info.ok) {
const data = await info.json();
return data.followers
}

const goal = 'mars'
const _ = await opp(goal)
const opp = async (username) => {
const info = await fetch('https://nekoweb.org/api/site/info/' + username, {
cache: 'no-cache'
});
const data = await info.json();
return data.followers
}

document.getElementById('follow-text').innerText = `(thnlqd) ${data.followers}/${_} (${goal})`;
document.getElementById('follow-progress').value = (data.followers / _) * 100;
const goal = 'mars'
const _ = await opp(goal)

document.getElementById('follow-text').innerText = `(thnlqd) ${data.followers}/${_} (${goal})`;
document.getElementById('follow-progress').value = (data.followers / _) * 100;
} else {
document.getElementById('follow-text').innerText = 'unable to fetch data';
}
</script>
</body>
</html>

0 comments on commit 523b955

Please sign in to comment.