Why the error unresolved import "hyper::client::Client"
?
#2967
Answered
by
seanmonstar
frederikhors
asked this question in
Q&A
-
Platform Description [package]
name = "demo"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
hyper = { version = "0.14.20", features = ["client"] }
tokio = { version = "1.20.1", features = ["full"] }
tracing = { version = "0.1.36", features = ["log"] } I'm getting this error:
Using the below code: use hyper::{client::Client, header, Request};
#[tokio::main]
async fn main() {
let hyper_client = Client::new();
let req = Request::builder()
.uri("http://google.com")
.header(header::CONTENT_TYPE, "application/json")
.body(hyper::Body::empty())
.unwrap();
let resp = hyper_client.request(req).await.unwrap();
println!("{:?}", resp);
} It works if I use this line in
Why? |
Beta Was this translation helpful? Give feedback.
Answered by
seanmonstar
Aug 25, 2022
Replies: 1 comment 4 replies
-
As the docs page shows, you need both |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
frederikhors
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As the docs page shows, you need both
client
and eitherhttp1
orhttp2
enabled.