A simple HTTP client for Bevy. It works on WASM and native platforms.
```rust use std::time::Duration;
use bevy::{app::ScheduleRunnerPlugin, prelude::}; use bevy_http_client::;
fn main() {
App::new()
.addplugins(
MinimalPlugins.set(ScheduleRunnerPlugin::runloop(Duration::fromsecsf64(
1.0 / 60.0,
))),
)
.addplugins(HttpClientPlugin)
.initresource::
pub struct ApiTimer(pub Timer);
impl Default for ApiTimer { fn default() -> Self { Self(Timer::from_seconds(1.0, TimerMode::Repeating)) } }
fn send_reqwest(mut commands: Commands, time: Res
if timer.just_finished() {
let req = ehttp::Request::get("https://api.ipify.org?format=json");
commands.spawn(HttpRequest(req));
}
}
fn handleresponse(
mut commands: Commands,
mut responses: Query<(Entity, &HttpResponse), Without
```