microsoft / microsoft/Web-Dev-For-Beginners
browser-extension project: Add Fallback for Missing API Response Data
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 96.7k
- Forks
- 15.9k
- PR merge metrics
- No merged PRs in 30d
Description
The displayCarbonUsage function assumes response.data.data contains carbonIntensity and fossilFuelPercentage, but missing data could cause errors. Adding checks (e.g., if (response.data.data?.carbonIntensity == null) { throw new Error('Missing carbon intensity data'); }) would prevent runtime errors and allow for graceful fallback (e.g., displaying “Data unavailable” for missing fields).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Search the browser-extension code for displayCarbonUsage and inspect how response.data.data is read. Trace the current handling of absent carbonIntensity and fossilFuelPercentage values, then decide on consistent fallback behavior from the issue’s requirements. Done means missing API fields no longer cause an unhandled runtime error and the unavailable data is handled visibly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100