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

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

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

vinay-khatri opened this issue Nov 30, 2024 · 0 comments
Labels

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant