'Rust - json method not found in `Result<reqwest::blocking::Response, reqwest::Error>`
I want to use reqwest but i can't i have an error :
let users: Vec<User> = response.json();
^^^^ method not found in `Result<reqwest::blocking::Response, reqwest::Error>
this is my code :
use reqwest::Error;
use tokio;
#[derive(Deserialize, Debug)]
struct User {
origin: String
}
#[tokio::main]
pub fn main() {
let request_url = format!("https://api.ipify.org");
println!("{}", request_url);
let response = reqwest::blocking::get(&request_url);
let users: Vec<User> = response.json();
println!("{:?}", users);
}
my dependencies :
[dependencies]
serde = { version = "1.0.136", features = ["derive"]}
reqwest = { version = "0.11.9", features = ["blocking", "json"]}
tokio = { version = "1.17.0", features = ["full"] }
why would this happen? what should I do to fix this problem?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
