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

dx serve build fails when using cookies feature on reqwest crate #2099

Closed
1 of 3 tasks
Harjun751 opened this issue Mar 18, 2024 · 1 comment
Closed
1 of 3 tasks

dx serve build fails when using cookies feature on reqwest crate #2099

Harjun751 opened this issue Mar 18, 2024 · 1 comment

Comments

@Harjun751
Copy link

Problem

As per title. Everything works fine until using a method provided only in the cookies feature. The project builds fine using cargo build

Error: 🚫 Serving project failed: error[E0599]: no method named `cookie_store` found for struct `ClientBuilder` in the current scope
--> src\main.rs:21:42
   |
21 |     let cli = reqwest::Client::builder().cookie_store(true).build().unwrap();
   |                                          ^^^^^^^^^^^^ method not found in `ClientBuilder`

My main.rs:

#![allow(non_snake_case)]
// import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types
use dioxus::prelude::*;

fn main() {
    // launch the web app
    dioxus_web::launch(App);
}

// create a component that renders a div with the text "Hello, world!"
fn App(cx: Scope) -> Element {
    cx.render(rsx! {
        div {
            "Hello, world!"
        }
    })
}

async fn brokey(){
    let endpoint = format!("http://dinguswingus.com/dingus");
    let cli = reqwest::Client::builder().cookie_store(true).build().unwrap();

    cli.post(endpoint).send().await;
}

Steps To Reproduce

Steps to reproduce the behavior:
Create a new demo project as usual, then add reqwests with cookies

  • cargo new --bin demo
  • cargo add dioxus
  • cargo add dioxus-web
  • cargo add reqwest --features cookies
  • Add some code that uses the cookies feature, like below:
async fn brokey(){
    let endpoint = format!("http://dinguswingus.com/dingus");
    let cli = reqwest::Client::builder().cookie_store(true).build().unwrap();

    cli.post(endpoint).send().await;
}

Expected behavior

The build doesn't fail :(

Environment:

  • Dioxus version: 0.4.3
  • dioxus-cli version: Tried 0.4.3, and 0.5.0-alpha.2
  • Rust version: 1.74.0
  • OS info: Windows
  • App platform: web

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later
@ealmloff
Copy link
Member

cargo build will build an application that targets your current platform. cargo build --target wasm32-unknown-unknown will build an application that targets WASM (like dioxus web). reqwest. It looks like reqwest doesn't support cookies in wasm: seanmonstar/reqwest#1449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants