use bevy::{prelude::*, time::common_conditions::on_timer}; use bevy_http_client::prelude::*; fn main() { App::new() .add_plugins((MinimalPlugins, HttpClientPlugin)) .add_systems(Update, (handle_response, handle_error)) .add_systems( Update, send_request.run_if(on_timer(std::time::Duration::from_secs(1))), ) .run(); } fn send_request(mut ev_request: EventWriter) { let request = HttpClient::new().get("https://api.ipify.org").build(); ev_request.send(request); } fn handle_response(mut ev_resp: EventReader) { for response in ev_resp.read() { println!("response: {:?}", response.text()); } } fn handle_error(mut ev_error: EventReader) { for error in ev_error.read() { println!("Error retrieving IP: {}", error.err); } }