Closed iamwyh2019 closed 3 years ago
@GrayFlash and Co. due to the criticality of this issue, I reassigned to Sumana and Co. The way we currently consume our API is too expensive.
Hey @grace-omotoso @Young-Einstein10 and @Shubh4m-B have already solved this issue by using debounce in their PR #15. They have added a function where if the search term has not been updated for more than 500ms, then only the API will be called. If you want we can increase that time a bit, but other than that, I think all the work has been already done by them. Let me know what you think.
@sumana2001, no worries. I will close this issue
Our site fetches weather data whenever the input box is changed. Say when user types "Chicago", it calls the api for "C", "Ch", "Chi", etc. This causes lots of unnecessary calls and easily exceeds free API limit. I suggest we only fetch the weather when user completes input. We can add a timer that calls
useWeather
in one second (something likesetTimeout
), and when the input box is changed the timer is reset.