Skip to content

Instantly share code, notes, and snippets.

@albert-tomanek
Created July 12, 2023 12:21
Show Gist options
  • Save albert-tomanek/e3a739454ec9656affbe03499a00c93b to your computer and use it in GitHub Desktop.
Save albert-tomanek/e3a739454ec9656affbe03499a00c93b to your computer and use it in GitHub Desktop.
// autocxx
extern crate tokio;
use lemmy_api_common::post;
use reqwest::{Client};
#[tokio::main]
async fn main() {
println!("Hello, world!");
let params = post::GetPosts {
community_name: Some("asklemmy".to_string()),
..Default::default()
};
let client = Client::new();
let response = client
.get("https://lemmy.ml/api/v3/post/list")
// .query(&params)
.send()
.await;
let json = response.expect("").text().await.unwrap();
// let json = response.expect("").json::<post::GetPostsResponse>().await.unwrap();
print!("{:?}", &json);
}
// prints: "<html>\r\n<head><title>403 Forbidden</title></head>\r\n<body>\r\n<center><h1>403 Forbidden</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment