I am translating code to version 1.0.1 of Tokio and version 0.10.10 of reqwest. This code does not work:
// Cargo.toml dependencies:
// reqwest = "0.10.10"
// tokio = { version = "1.0.1", features = ["full"] }
#[tokio::main]
async fn main() {
let response = reqwest::get("https://baconipsum.com/api/?type=meat-and-filler&type=text¶s=1").await.unwrap();
let text = response.text().await.unwrap();
println!("{}", text);
}
The program fails at runtime with this message:
thread 'main' panicked at 'not currently running on the Tokio runtime.', /home/pk/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/runtime/handle.rs:118:28
stack backtrace:
The code is basically same as reqwest's simple example - but that was written for an older Tokio version.
I shared the code on the Rust playground but it doesn't even compile there.