Proposal: response.base64() #1800
Labels
addition/proposal
New features or enhancements
needs implementer interest
Moving the issue forward requires implementers to express interest
topic: api
What problem are you trying to solve?
Problem Statement
Currently, when working with the Fetch API, converting response data to base64 encoding requires multiple steps and introduces complexity, especially when handling binary data. Developers often need to:
This process is error-prone and requires additional code that could be standardized.
What solutions exist today?
Existing Solutions
Currently, developers typically handle this in one of these ways:
Both approaches have drawbacks:
How would you solve it?
Proposed Solution
Add a new method
base64()
to the Response prototype:Example usage:
Implementation Details
The method would:
Benefits
Compatibility
The method name
base64()
is not currently used in the Response prototype, making it safe to add. The method would return a Promise to maintain consistency with other Response body reading methods.Additional Considerations
Security
Edge Cases
Performance Impact
Anything else?
Open Questions
The text was updated successfully, but these errors were encountered: