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

Headers field unused on WASM #57

Open
Strosel opened this issue Jun 5, 2024 · 1 comment
Open

Headers field unused on WASM #57

Strosel opened this issue Jun 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Strosel
Copy link

Strosel commented Jun 5, 2024

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 the RequestInit instead. I might be able to test this and make a PR later this week.

@emilk emilk added the bug Something isn't working label Jul 15, 2024
@chianti-ga
Copy link

@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(),
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants