This commit is contained in:
2022-10-02 10:38:14 +05:30
parent 3db883225b
commit 543ae918f7

View File

@@ -9,7 +9,7 @@ use tower_http::trace::TraceLayer;
#[derive(Deserialize, Serialize, Debug)] #[derive(Deserialize, Serialize, Debug)]
struct Books { struct Books {
numFound: u32, num_found: u32,
} }
// Setup the command line interface with clap. // Setup the command line interface with clap.
@@ -64,7 +64,10 @@ async fn main() {
async fn hello() -> impl IntoResponse { async fn hello() -> impl IntoResponse {
//"hello from server!" //"hello from server!"
let res = reqwest::get("https://openlibrary.org/search.json?q=the+lord+of+the+rings").await?; let res = reqwest::get("https://openlibrary.org/search.json?q=the+lord+of+the+rings")
let resjson = res.json::<Books>().await; .await
.expect("Unable to request");
let resjson = res.json::<Books>().await.expect("Unable to return value");
return Json(resjson); return Json(resjson);
} }