Skip to content

Enhancement : Added API caching, loading states, and real-time search … - #1

Open
codeCraft-Ritik wants to merge 1 commit into
masiimc:mainfrom
codeCraft-Ritik:main
Open

Enhancement : Added API caching, loading states, and real-time search …#1
codeCraft-Ritik wants to merge 1 commit into
masiimc:mainfrom
codeCraft-Ritik:main

Conversation

@codeCraft-Ritik

Copy link
Copy Markdown

Summary of Code Updates

The following improvements were made to transition the project from a basic static site to a more professional, performance-oriented web application:

  • API Rate-Limit Protection (Caching): Implemented localStorage logic in price1.html to cache cryptocurrency data for 60 seconds. This prevents the "429 Too Many Requests" error commonly encountered with the CoinGecko free API during frequent refreshes.
  • Modern Asynchronous Architecture: Refactored data fetching from old .then() promise chains to modern async/await syntax for better readability and error management.
  • Live Search Functionality: Integrated a real-time search filter in js/price.js that monitors the search input and dynamically hides or shows table rows based on the coin's name or symbol.

Enhanced User Experience (UX):

  • Added a "Loading..." state to the UI so users are informed while data is being fetched.
  • Implemented visible error messages if the API request fails.

Data Formatting & Cleanliness:

  • Updated the currency display using .toLocaleString() to show professional formatting (e.g., $ 50,000.00 instead of 50000).

  • Consolidated color-coding logic to highlight positive and negative 24h changes.

  • Code Maintainability: Cleaned up selectors and added safety checks (e.g., if (slider)) to prevent JavaScript errors across different pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant