sadanandpai / frontend-mini-challenges

Collection of frontend challenges for learning and interviews
https://sadanandpai.github.io/frontend-mini-challenges/
MIT License
1.96k stars 483 forks source link

[React/autocomplete] Handle error when rate limit is breached - closes #330 #331

Closed kan-ish closed 8 months ago

kan-ish commented 8 months ago

Error handling. Issue #330

Title : Handled API response 403. Added visual elements with better information for the user.

Description:

Added a countdown timer when the API limit is breached. The timer counts down till when the rate-limit will reset and the user can start making requests again. Time is calculated from the response header "x-ratelimit-reset" which is received when the API limit is breached along with http status code 403.

Further Context:

The API responds with a 403 Forbidden because beyond 10 requests per minute (which is the rate-limit for unauthenticated requests), it expects the requests to be authenticated. The ideal way to handle this would be to make the user login into GitHub before they can start searching, but this solution seems repelling for someone who is just on the website to check out "mini" challenges. In that case, the committed solution seems best to me.

Video of the implemented solution: https://github.com/sadanandpai/frontend-mini-challenges/assets/67118535/202e6bd7-f0ca-4838-9fa2-96b89546515b

Issue No. : #330

Code Stack : React

Close #330

Checklist:

netlify[bot] commented 8 months ago

Deploy Preview for preeminent-tapioca-4294b2 canceled.

Name Link
Latest commit 04d54777cdafbea6d9c220c5b7ff0c15051d7712
Latest deploy log https://app.netlify.com/sites/preeminent-tapioca-4294b2/deploys/654a5f01b9daf700087dcf55