#Future is not implemented for Task

1 messages · Page 1 of 1 (latest)

stray forge
#

So I'm following the docs (with a few personal modifications) to try and get a request sent on some event, https://dioxuslabs.com/learn/0.5/reference/spawn.

So far I have this

fn App() {
    let mut stories = use_signal(|| String::new());

    let find_story = move |event: Event<FormData>| {
        spawn({
           to_owned![stories];

            async move {
                stories.set(
                    reqwest::get(format!(
                        "http://127.0.0.1:8888/stories?story_name={}",
                        event.value(),
                     ))
                     .await
                     .unwrap()
                     .text()
                     .await
                     .unwrap(),
                );
             }
        })
    };

    rsx! {
        div {
           "{stories}"
        }
        input {
            value: "Story name",
            // and what to do when the value changes
            oninput: find_story,
        }
    }
}

But it's decided that there's something wrong with that, and has spat out this.

error[E0277]: `Task` is not a future
   --> crates/library_frontend/src/main.rs:35:5
    |
35  | /     rsx! {
36  | |         div {
37  | |             "{stories}"
38  | |         }
...   |
46  | |         }
47  | |     }
    | |_____^ `Task` is not a future
    |
    = help: the trait `Future` is not implemented for `Task`
    = note: Task must be a future or must implement `IntoFuture` to be awaited
    = help: the trait `EventReturn<()>` is implemented for `()`
    = note: required for `Task` to implement `EventReturn<AsyncMarker>`
note: required by a bound in `onclick`

Probably a minor thing but I can't for the life of me figure out what it is

I'm using the latest version of dioxus with the liveview and axum features enabled.

stray forge
#

ffs

#

I figured it out

#

I missed one ;

#

at the end of the spawn function