ofetch icon indicating copy to clipboard operation
ofetch copied to clipboard

Bun compatibility

Open chriscdn opened this issue 1 year ago • 0 comments

Describe the feature

I tried ofetch with Bun. It seems to work, but I ran into a small issue when POSTing multipart/form-data. It seems the Bun FormData class has a toJSON method, while Node and Deno do not. It causes the isJSONSerializable() method to return true (exact line below), and therefore sends the serialized payload as application/json instead of multipart/form-data.

Would a value instanceof FormData check make sense here?

https://github.com/unjs/ofetch/blob/7726adbf10a5a233ae98cb8adb619864b012db65/src/utils.ts#L36

Additional information

  • [ ] Would you be willing to help implement this feature?

chriscdn avatar Sep 03 '24 20:09 chriscdn