How to send `FormData` via `Fetch`? I
How to send
FormData
via Fetch
? I don't see Into<JsValue>
implementation on the FormData
struct.4 Replies
Apparently, there's no way to use exposed
FormData
for a request body, so I just build a string manually (I don't send any files yet, so it supports only text fields):
FWIW, you can also use reqwest which has a nicer API than the workers-provided Fetch
e.g., this is how I interact with the CloudFlare "images" API, which also uses form data:
@alex35mil How did you put the manually constructed string into the request body? Attempting to assign it with
RequestInit.with_body
results in an error because it's not of type JsValue
.@natsumesou you can call
.into()
on a string to turn it into JsValue
since the latter implements From<String>