-
Notifications
You must be signed in to change notification settings - Fork 161
Description
Description
Currently on the Giveaways page(https://techxninjas-client.vercel.app/giveaways), the "Discover Fact" button does not work as intended. It shows an error saying, "Error:
Gemini API Key is not configured. Please contact administrator."
This appears to be due to the Gemini API key not being set in the deployed environment, which is understandable for security reasons. However, the UI lacks graceful handling of this failure.
To Reproduce
Steps to reproduce the behavior:
- Visit https://techxninjas-client.vercel.app/giveaways
- Click on the orange button with white text as "Discover Fact".
- The error is shown in a red banner saying: "Error: Gemini API Key is not configured. Please contact administrator."
Expected behavior
If the Gemini API key is present and valid:
-> Fetch and display the AI-generated tech fact using Gemini API.
If the Gemini API key is misconfigured or invalid:
-> Fetch some locally available tech facts as fallback.
Screenshots

Suggested Fix
Implement a fallback mechanism using a small local JSON/array of predefined tech facts.
When the Gemini API call fails, catch the error and randomly select a local fallback fact to display.
Optionally, add a console warning for developers if the API key is not present, but suppress the red banner on the UI for end users.
Additional context
This will ensure the user experience remains smooth even if the external AI service is down or unavailable.
Many platforms avoid blocking UI features due to external service configuration by including intelligent fallback logic.