Portfolio Dashboard: How to fetch API data (GitHub/LeetCode) in a static Vite app without rate limits? #200254
-
|
Hey guys! I'm currently in my 2nd semester of CS and building my first real portfolio website on the side to practice web dev. I'm using a static setup with Vite and Vanilla JS. I want to pull my GitHub activity and maybe some LeetCode stats into a small dashboard section. But since I don't have a backend (just static HTML/JS), how do I handle API rate limits? I don't want the API to block requests if someone refreshes the page a few times. Also, how do I hide my API keys if I need them for the requests? Since we mostly do Java at uni, I'm a bit lost on the best practice for static frontend apps here. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hey! I ran into the exact same issue when building my Vite portfolio. Coming from our uni Java projects, the whole static frontend thing takes a minute to get used to. Since you don't have a backend, you basically have two clean ways to solve this, depending on what the API requires: 1. The pure frontend way:
2. The modern approach: Serverless Functions
My tip: Start with Good luck with the project! :) |
Beta Was this translation helpful? Give feedback.
Hey! I ran into the exact same issue when building my Vite portfolio. Coming from our uni Java projects, the whole static frontend thing takes a minute to get used to.
Since you don't have a backend, you basically have two clean ways to solve this, depending on what the API requires:
1. The pure frontend way:
localStoragecachingIf the API is public and doesn't need a secret token, just cache the data right in the browser!
localStorage.setItem()to save the JSON and a timestamp. On the next page reload, check if the timestamp is older than, say, an hour. If not, just load the saved JSON.