{"id":17994940,"url":"https://github.com/totalkrill/bevy_mod_reqwest","last_synced_at":"2025-04-05T14:04:50.880Z","repository":{"id":151333904,"uuid":"624107512","full_name":"TotalKrill/bevy_mod_reqwest","owner":"TotalKrill","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-03T12:50:47.000Z","size":99,"stargazers_count":31,"open_issues_count":2,"forks_count":14,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T13:05:54.961Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TotalKrill.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-05T19:01:10.000Z","updated_at":"2025-03-01T04:34:09.000Z","dependencies_parsed_at":"2024-06-14T06:39:39.094Z","dependency_job_id":"d803396c-5644-4ab3-bd09-e290aa02f039","html_url":"https://github.com/TotalKrill/bevy_mod_reqwest","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TotalKrill%2Fbevy_mod_reqwest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TotalKrill%2Fbevy_mod_reqwest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TotalKrill%2Fbevy_mod_reqwest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TotalKrill%2Fbevy_mod_reqwest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TotalKrill","download_url":"https://codeload.github.com/TotalKrill/bevy_mod_reqwest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345850,"owners_count":20924102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-29T20:17:15.268Z","updated_at":"2025-04-05T14:04:50.860Z","avatar_url":"https://github.com/TotalKrill.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bevy_mod_reqwest\n\n[![crates.io](https://img.shields.io/crates/v/bevy_mod_reqwest)](https://crates.io/crates/bevy_mod_reqwest)\n[![docs.rs](https://docs.rs/bevy_mod_reqwest/badge.svg)](https://docs.rs/bevy_mod_reqwest)\n\nThis crate helps when trying to use reqwest with bevy, without having to deal with async stuff, and it works on both web and and native\n( only tested on x86_64 and wasm for now)\n\n| Bevy version | bevy_mod_reqwest version |\n| ------------ | ------------------------ |\n| 0.15         | 0.18                     |\n| 0.14         | 0.15 - 0.17              |\n| 0.13         | 0.14                     |\n| 0.12         | 0.12 - 0.13              |\n\n## Example\n\n``` rust\nuse std::time::Duration;\n\nuse bevy::{log::LogPlugin, prelude::*, time::common_conditions::on_timer};\nuse bevy_mod_reqwest::*;\n\n#[derive(Default, Resource)]\n// just a vector that stores all the responses as strings to showcase that the `on_response` methods\n// are just regular observersystems, that function very much like regular systems\nstruct History {\n    pub responses: Vec\u003cString\u003e,\n}\n\nfn send_requests(mut client: BevyReqwest) {\n    let url = \"https://bored-api.appbrewery.com/random\";\n\n    // use regular reqwest http calls, then poll them to completion.\n    let reqwest_request = client.get(url).build().unwrap();\n\n    client\n        // Sends the created http request\n        .send(reqwest_request)\n        // The response from the http request can be reached using an observersystem,\n        // where the only requirement is that the first parameter in the system is the specific Trigger type\n        // the rest is the same as a regular system\n        .on_response(\n            |trigger: Trigger\u003cReqwestResponseEvent\u003e, mut history: ResMut\u003cHistory\u003e| {\n                let response = trigger.event();\n                let data = response.as_str();\n                let status = response.status();\n                // let headers = req.response_headers();\n                bevy::log::info!(\"code: {status}, data: {data:?}\");\n                if let Ok(data) = data {\n                    history.responses.push(format!(\"OK: {data}\"));\n                }\n            },\n        )\n        // In case of request error, it can be reached using an observersystem as well\n        .on_error(\n            |trigger: Trigger\u003cReqwestErrorEvent\u003e, mut history: ResMut\u003cHistory\u003e| {\n                let e = \u0026trigger.event().0;\n                bevy::log::info!(\"error: {e:?}\");\n                history.responses.push(format!(\"ERROR: {e:?}\"));\n            },\n        );\n}\n\nfn main() {\n    App::new()\n        .add_plugins(MinimalPlugins)\n        .add_plugins(LogPlugin::default())\n        .add_plugins(ReqwestPlugin::default())\n        .init_resource::\u003cHistory\u003e()\n        .add_systems(\n            Update,\n            send_requests.run_if(on_timer(Duration::from_secs(5))),\n        )\n        .run();\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftotalkrill%2Fbevy_mod_reqwest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftotalkrill%2Fbevy_mod_reqwest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftotalkrill%2Fbevy_mod_reqwest/lists"}