Skip to content
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

bug: [CapacitorHttp] response.text() does not work on responses with Content-Type: application/json #6184

Closed
silviogutierrez opened this issue Dec 21, 2022 · 2 comments

Comments

@silviogutierrez
Copy link

silviogutierrez commented Dec 21, 2022

Bug Report

Capacitor Version

💊   Capacitor Doctor  💊

Latest Dependencies:

  @capacitor/cli: 4.6.1
  @capacitor/core: 4.6.1
  @capacitor/android: 4.6.1
  @capacitor/ios: 4.6.1

Installed Dependencies:

  @capacitor/cli: 4.6.1
  @capacitor/core: 4.6.1
  @capacitor/ios: 4.6.1
  @capacitor/android: 4.6.1

[success] iOS looking great! 👌
[success] Android looking great! 👌

Platform(s)

  • iOS
  • Web

Current Behavior

Related to #6170. Even if you try to work around the buggy behavior (strings, numbers and booleans are valid JSON and should be parsed) by calling response.text() instead of response.json(), Capacitor has already tried to parse this as JSON and return JSON for the data instead of the raw string.

It should return the raw string

Expected Behavior

Calling response.text() on a response should return plain text, even if the headers indicate this is JSON.

Code Reproduction

See #6177, but for convenience:

Go to https://github.com/silviogutierrez/capacitor-http-tester and clone the repository.

Run npm install and npm cap sync to get both emulators working.

Then run npm run build && node server.js to start the local server.

Now open http://localhost:3000 and see how everything works on the browser.

After that run npx cap open iOS and run the simulator. And npx cap open android and run the emulator.

This issue number and text case will be shown as failing on both iOS and Android, but passing on web.

@jcesarmobile
Copy link
Member

Can't reproduce on Capacitor 5.7.0

Copy link

ionitron-bot bot commented Mar 21, 2024

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants