Skip to content

wasm http-request doesn't return #48

Closed

Description

@wgtun

Hello, I would like to ask a question, I added a http request code, the mobile is normal, but the web does not return, I want to know where is my problem, web http request code like this:

use gloo_net::http::{Headers, Request};
#[tokio::main(flavor = "current_thread")]
pub fn request(params: MyRequest) -> Result<String> {
            let headers = get_web_default_headers().unwrap();
            for header in &params.headers {
                headers.set(&header.key, &header.value);
            }
            let result = Request::get(&params.url).headers(headers).send().await?;
            Ok(result.text().await?)
}

Activity

  1. Desdaemon commented on Jul 13, 2023

    @Desdaemon
    Owner

    You'll need to use #[cfg] attributes to enable Tokio only for non-web users and wasm-bindgen-futures for web users. Also I'll open discussions so common questions like this can be collected in one place.

  2. Repository owner locked and limited conversation to collaborators on Jul 13, 2023
  3. converted this issue into a discussion #50 on Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions