File size: 424 Bytes
998b6cc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
use serde::Deserialize;
use reqwest;
#[derive(Deserialize, Debug)]
struct Todo {
#[serde(rename = "userId")]
user_id: i32,
id: i32,
title: String,
completed: bool,
}
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let todo: Todo = reqwest::get("https://jsonplaceholder.typicode.com/todos/1")
.await?
.json()
.await?;
println!("{:?}", todo);
Ok(())
} |