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]: Capacitor HTTP plugin does not set data for fetch with Request #7371

Closed
2 of 3 tasks
michaelkhabarov opened this issue Mar 29, 2024 · 5 comments
Closed
2 of 3 tasks
Labels
needs reproduction needs reproducible example to illustrate the issue

Comments

@michaelkhabarov
Copy link

Capacitor Version

Latest Dependencies:

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

Installed Dependencies:

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

Other API Details

npm --version
10.2.0

node --version
v20.8.0

pod --version
1.14.0

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

Sending fetch request with Request object as a parameter does not set data for request. This makes Capacitor HTTP incompatible with popular ky library.

request = new Request("http://192.168.1.11:3000/clients/auth/verification_code", { method: "POST" })
request.headers.set("Content-Type", "application/json")
request.body = JSON.stringify({"phone": "1234567890"}) // <-- this is ignored
await fetch(request)
Screenshot 2024-03-29 at 04 03 16

Expected Behavior

Expect passing Request to fetch parameter to send body of request object

Project Reproduction

none, can be reproduced without a repo

Additional Information

No response

@jcesarmobile jcesarmobile added the needs reproduction needs reproducible example to illustrate the issue label Apr 1, 2024
Copy link

ionitron-bot bot commented Apr 1, 2024

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed.
Please see the Contributing Guide for how to create a Sample App.
Thanks! Ionitron 💙

@ionitron-bot ionitron-bot bot removed the triage label Apr 1, 2024
@Ionitron Ionitron added needs reply needs reply from the user and removed needs reply needs reply from the user labels Apr 1, 2024
@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Apr 1, 2024
@WurstMitBrot
Copy link

WurstMitBrot commented Apr 10, 2024

I faced a similiar issue. I'm using the Capacitor Http plugin in combination with rtk query.
The plugin config looks like follows:

With version 5.7.0 everything worked, after switching to 5.7.4 the error occured.

plugins: { CapacitorHttp: { enabled: true, }, },

When making a post request i get the following error:
Using fetch:
image

Using RTK Query:
image

To reproduce the issue i created the following project:
https://github.com/WurstMitBrot/capacitor-fetch-example

@Ionitron Ionitron removed the needs reply needs reply from the user label Apr 10, 2024
@jcesarmobile
Copy link
Member

WurstMitBrot, since you say it's a similar issue, but might not be the same problem, can you create a separate issue for your problem?

@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Apr 10, 2024
@WurstMitBrot
Copy link

WurstMitBrot, since you say it's a similar issue, but might not be the same problem, can you create a separate issue for your problem?

Thanks for your answer, created a new issue.

@Ionitron Ionitron removed the needs reply needs reply from the user label Apr 11, 2024
@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Apr 11, 2024
@Ionitron
Copy link
Collaborator

It looks like this issue didn't get the information it needed, so I'll close it for now. If I made a mistake, sorry! I am just a bot.

Have a great day!
Ionitron 💙

@Ionitron Ionitron removed the needs reply needs reply from the user label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reproduction needs reproducible example to illustrate the issue
Projects
None yet
Development

No branches or pull requests

4 participants