Open Strosel opened 3 months ago
@Strosel I got around this by using custom functions/implementations of Request
Post json content for exemple:
fn post_json(url: String, body: Vec<u8>) -> Request {
Request {
method: "POST".to_owned(),
url: url,
body,
headers: Headers::new(&[
("Accept", "*/*"),
("Content-Type", "application/json; charset=utf-8"),
]),
#[cfg(target_arch = "wasm32")]
mode: Mode::default(),
}
}
It seems that the headers field of the
Request
struct remains unused when compiling to WASM. From what I can tell this is because they are set via a getter here and therefore remain unused.From a quick glance at the web-sys docs the correct way to set headers is by passing a
Headers
struct to theRequestInit
instead. I might be able to test this and make a PR later this week.