This commit is contained in:
mightypanders 2023-02-14 15:45:18 +01:00
parent bfcbe1ffa5
commit a640af5ed4

38
src/main.rs Normal file
View File

@ -0,0 +1,38 @@
use std::env;
use dotenv::dotenv;
use reqwest::{self, Client};
#[tokio::main]
async fn main() {
dotenv().ok();
let api_token = env::var("TANDOOR_TOKEN").expect("Token needed");
let base_url = env::var("TANDOOR_BASE_URL").expect("Base Url needed");
let route = "/shopping-list-entry/";
let url = format!("{}{}", base_url, route);
println!("{url}");
let client = Client::new();
let req = client
.get(&url)
.query(&[("checked", "false")])
.bearer_auth(api_token);
match req.send().await {
Ok(resolved) => match resolved.status() {
reqwest::StatusCode::OK => {
//println!("Success {:#?}", resolved);
println!("{}", resolved.text().await.unwrap())
}
reqwest::StatusCode::FORBIDDEN => {
println!("Denied {:#?}", resolved)
}
_ => {
println!("Fail {:#?}", resolved);
}
},
Err(failed) => {
println!("There was an error in the reqwest: {failed}")
}
}
}