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

[feat] http.fetch may be support formData #5545

Closed
Sneaken opened this issue Nov 4, 2022 · 3 comments
Closed

[feat] http.fetch may be support formData #5545

Sneaken opened this issue Nov 4, 2022 · 3 comments

Comments

@Sneaken
Copy link

Sneaken commented Nov 4, 2022

Describe the problem

i need use FormData in CORS fetch

Describe the solution you'd like

rust can parse my FormData and request again

Alternatives considered

No response

Additional context

No response

@FabianLars
Copy link
Member

FabianLars commented Nov 4, 2022

If you add the "http-multipart" feature flag to the tauri dependency in Cargo.toml it should work. If not please provide a code example of what you're trying to do.

Edit: I think you have to set the Content-Type header yourself on request 🤔

@Sneaken
Copy link
Author

Sneaken commented Nov 4, 2022

If you add the "http-multipart" feature flag to the tauri dependency in Cargo.toml it should work. If not please provide a code example of what you're trying to do.

Edit: I think you have to set the Content-Type header yourself on request 🤔

i add the http-multipart and then how to use ?

for example:

import { http } from '@tauri-apps/api';

const formData = new FormData();
formData.append('msg', 'test_message');

await http
      .fetch('some_url', {
        method: 'POST',
        headers: {
          'content-type': 'multipart/form-data',
        },
        body: http.Body.form(formData) // how can i do ?
      })

@lucasfernog
Copy link
Member

That's right @Sneaken though i'm not sure if it supports a FormData object, let me check. Any regular JS object should work.

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

No branches or pull requests

3 participants