working get reqest of all notes

This commit is contained in:
Nickiel12 2023-08-20 20:34:31 -07:00
parent cdaf8bd130
commit 5fe2d9b599
3 changed files with 44 additions and 4 deletions

19
Cargo.lock generated
View file

@ -652,9 +652,23 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.183" version = "1.0.184"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" checksum = "2c911f4b04d7385c9035407a4eff5903bf4fe270fa046fda448b69e797f4fff0"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.184"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1df27f5b29406ada06609b2e2f77fb34f6dbb104a457a671cc31dbed237e09e"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "serde_json" name = "serde_json"
@ -713,6 +727,7 @@ name = "status_cloud"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"reqwest", "reqwest",
"serde",
] ]
[[package]] [[package]]

View file

@ -7,3 +7,4 @@ edition = "2021"
[dependencies] [dependencies]
reqwest = { version = "0.11.18", features = ["blocking", "json"] } reqwest = { version = "0.11.18", features = ["blocking", "json"] }
serde = { version = "1.0.184", features = ["serde_derive"] }

View file

@ -1,3 +1,27 @@
fn main() { use serde::{Deserialize, Serialize};
println!("Hello, world!"); use reqwest::blocking::Client;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let res = client
.get("https://username:password@files.nickiel.net/index.php/apps/notes/api/v1/notes")
.header("Accept", "application/json")
.send()?
.json::<Vec<Note>>()?;
println!("{:#?}", res);
Ok(())
}
#[derive(Serialize, Deserialize, Debug)]
struct Note {
id: usize,
etag: String,
readonly: bool,
modified: u64,
title: String,
category: String,
content: String,
favorite: bool
} }