9
My first API call crashed my browser with a 0.5MB JSON response
I was building a weather app for a class project and tried to pull forecast data for the whole US in one request. The browser froze for 2 minutes and then gave me a blank white screen. Has anyone else hit a wall with huge API payloads on their first try?
2 comments
Log in to join the discussion
Log In2 Comments
joel28016d ago
Man that exact thing happened to me on my first project. I was grabbing a huge dataset from a government API and my page just died. What worked was adding pagination so I only pulled like 100 records at a time, and then I used a loading spinner to keep the UX smooth. Also started sending smaller query filters like dates or regions to cut down the payload size.
5
webb.stella16d ago
Wait, isn't pagination just pushing the problem down the road though? I mean, if you're building a real app people are going to want to search through that whole dataset eventually, not just the first 100 records. Those smaller query filters sound good but they usually make the server do way more work on the backend, and if the API isn't designed for that you're just trading a frontend crash for a slow server timeout. Plus, loading spinners are kind of a bandaid - your users are still sitting there waiting, even if it looks a little nicer. I'd rather just cache the whole dataset locally on first load and let the browser handle it with some smart lazy loading, or set up a web worker so the main thread doesn't freeze up. Maybe I'm wrong but it feels like we overcomplicate simple stuff when the real fix is just better frontend architecture.
6