Closed torhovland closed 1 year ago
There are FormData
bindings here: https://github.com/seed-rs/seed/blob/master/src/browser/fetch/form_data.rs
They just haven't been released yet.
(This also reminds me that I was supposed to make you an example for the leaflet bindings. Hopefully this weekend!)
Actually, that didn't quite work either. It insists on multipart/form-data
, while I need application/x-www-form-urlencoded
.
However, I found I could just do this:
Request::new(url)
.method(Method::Post)
.text(format!(
"grant_type=authorization_code&redirect_uri=http://127.0.0.1:8088/callback&code={}",
code
))
.header(Header::content_type("application/x-www-form-urlencoded"))
.fetch()
Perhaps this is as good as it gets, though. See https://stackoverflow.com/a/37562814
Oh right, you could probably also use UrlSearchParams
.
obsolete since v0.10.0
I need to POST form data to an endpoint that requires
Content-Type=application/x-www-form-urlencoded
. Specifically, this is an OAuth2 endpoint that doesn't seem to support JSON form data.