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]: FormData request failing with CapacitorHttp enabled #7783

Closed
1 of 3 tasks
vinay-khatri opened this issue Nov 30, 2024 · 2 comments
Closed
1 of 3 tasks

[Bug]: FormData request failing with CapacitorHttp enabled #7783

vinay-khatri opened this issue Nov 30, 2024 · 2 comments
Labels
needs reproduction needs reproducible example to illustrate the issue

Comments

@vinay-khatri
Copy link

Capacitor Version

Latest Dependencies:

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

Installed Dependencies:

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

Other API Details

npm v10.8.2
node v18.20.5

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

I am sending a multipart/form-data request from capacitor.js app in android to my hono backend. But my Hono app throwing an error when trying to parse this request. I send the same request from my website and it works absolutely fine.

When i explicitly set headers as "multipart/form-data", no request is being sent at all. I have also used CapacitorHttp.post() method and XMLHttpRequest but all failed.

const submitReview = () => {
        let formData = new FormData();
        for (var key in review) {
            formData.append(key, review[key]);
        }
        formData.append("image", newImage);
        formData.append("service_id", id);
        fetch(`${string.Api_Url}/v1/service/review`, {
            method: "POST",
            credentials: "include",
            body: formData,
        })
            .then((raw) => raw.json())
            .then((res) => {
                if (res.success) {
                    getService(id);
                    toastType = "success";
                    toastMessage = "Review Submitted";
                    showToast = true;
                } else {
                    console.log(res.error);
                    toastType = "error";
                    toastMessage = res.error;
                    showToast = true;
                }
            });
    };

Expected Behavior

I want my request to return json data.

Project Reproduction

Not Available

Additional Information

No response

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

ionitron-bot bot commented Dec 3, 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 Dec 3, 2024
@Ionitron Ionitron added needs reply needs reply from the user and removed needs reply needs reply from the user labels Dec 3, 2024
@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Dec 3, 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 Dec 19, 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

3 participants