Skip to content

browser-extension project: Add Fallback for Missing API Response Data #1548

@Joaquimdacosta1999

Description

@Joaquimdacosta1999

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions