-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parses response into json, not yet usable
- Loading branch information
1 parent
83a9f99
commit edd335d
Showing
3 changed files
with
29 additions
and
77 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
use reqwest::Result; | ||
#![allow(unused)] | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
struct WordOfTheDay { | ||
word: String, | ||
category: String, | ||
} | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let api_key = std::env::var("WORDNIK_API_KEY").unwrap(); | ||
let url = "https://api.wordnik.com/v4/words.json/randomWord?api_key=".to_owned() + &api_key; | ||
let response = reqwest::get(url).await?; | ||
let body = response.text().await?; | ||
println!("{}", body); | ||
let url = "https://api.wordnik.com/v4/words.json/wordOfTheDay?api_key=".to_owned() + &api_key; | ||
let response = reqwest::blocking::get(url)?.text()?; | ||
let json: serde_json::Value = serde_json::from_str(&response)?; | ||
println!("{:#?}", json); | ||
Ok(()) | ||
} |