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

🙏 How to send FormData with File in node environment? #347

Closed
1 task
gyhyfj opened this issue Jan 2, 2024 · 3 comments
Closed
1 task

🙏 How to send FormData with File in node environment? #347

gyhyfj opened this issue Jan 2, 2024 · 3 comments

Comments

@gyhyfj
Copy link

gyhyfj commented Jan 2, 2024

Describe the feature

In node environment (v20), I want to upload an image to OSS by posting FormData, I've tried several solutions, such as using form-data deps, but still failed.

It works well in web envrionment.

Additional information

  • Would you be willing to help implement this feature?
@Lpmvb
Copy link

Lpmvb commented Feb 28, 2024

@Loongphy
Copy link

use Native api just like fetch

ofetch.native('your_url', { method: 'POST', body: formData })

@pi0
Copy link
Member

pi0 commented Aug 28, 2024

Node.js supports built-in FormData since v18 powered by undici.

You can simply pass it as body and ofetch works with it.

PS: Using ofetch() and ofetch.native() should be equal. only difference is that ofetch.native returns full response object.

If you had further questions, please feel free to open a discussion with some of your code.

@pi0 pi0 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants