-
Notifications
You must be signed in to change notification settings - Fork 44
fix: angularHttpClient fetch error #359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
talissoncosta
commented
Nov 12, 2025
e5effa0 to
7232757
Compare
7232757 to
6b7760e
Compare
Zaimwa9
requested changes
Nov 17, 2025
Contributor
Zaimwa9
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for the comprehensive testing, just 2 comments
Zaimwa9
approved these changes
Nov 18, 2025
Contributor
Zaimwa9
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Angular HttpClient fetch adapter was not properly implementing the Fetch API interface, causing critical issues:
statusproperty[Object object]instead of actual contentThis prevented proper error handling in Angular applications using the Flagsmith SDK, making debugging difficult and breaking standard HTTP error flows.
Solution
Refactored
utils/angular-fetch.tsto properly bridge Angular's Observable-based HttpClient API with the standard Fetch API interface expected by the Flagsmith SDK.Key Changes
1. Added required Angular HttpClient options:
Why these are critical:
observe: 'response'- Angular returns only the body by default. This option gives us the fullHttpResponseobject withstatus,headers, andbody.responseType: 'text'- Angular auto-parses JSON responses. The SDK expects raw text to call.text()on the response, matching the Fetch API contract.2. Unified response transformation:
Created a
buildResponse()helper that transforms both success and error responses into a consistent Fetch-compatible format:Benefits:
okfield derivation based on HTTP status codes (200-299 = true)errorormessagefields[Object object]3. Improved error handling:
ok: false, matching Fetch API behavior4. Fixed JSON object stringification in text() method:
When Angular HttpClient returns JSON objects (even with
responseType: 'text'), thetext()method now properly stringifies them:Why this matters:
responseType: 'text'is set"[Object object]"when coerced to stringstext()to return a string, which is then parsed byJSON.parse()in the SDKflagsmith-core.tsline 865Testing
Unit Tests
Added comprehensive test suite with 12 test cases covering all scenarios in
test/angular-fetch.test.ts:Core functionality:
statusandokpropertiesheaders.get()methodError handling:
ok: falseok: falseEdge cases:
Test results:
npm test -- angular-fetch.test PASS test/angular-fetch.test.ts ✓ 12 tests passedManual Testing in Angular App
Quick setup with npm link:
Test scenarios:
[object Object]error[object Object]error[object Object]errorhasFeature()worksFiles Changed
utils/angular-fetch.ts- Core fix with proper response/error handling and JSON stringificationtest/angular-fetch.test.ts- New comprehensive test suite with 12 test casesBreaking Changes
None - This fix maintains backward compatibility while adding missing properties and fixing bugs.