I don't believe there is a simple example for an http request with bevy?
I'm looking to complete a minimum viable wasm example sending an http call and grabbing the result, and setting the response to text.
fn counter_system2(mut query: Query<&mut Counter>, mut query2: Query<&mut Text>) {
for mut fieldd in query.iter_mut() {
if fieldd.c_name == String::from("counter_two") {
fieldd.c += 2;
if fieldd.c % 100 == 0 {
let request = ehttp::Request::get("http://localhost:8081/test");
ehttp::fetch(request, move |result: ehttp::Result<ehttp::Response>| {
let v: Value = serde_json::from_slice(&result.unwrap().bytes).unwrap();
for mut text in &mut query2 {
text.sections[0].value = format!("new value from http req: {}", v);
}
});
}
}
}
}
Can someone show me how something like this could work with bevy? This doesn't work because I'm trying to use query2 inside the move.