main.rs 636 B

12345678910111213141516171819202122232425262728
  1. use serde::{Deserialize, Serialize};
  2. #[derive(Serialize,Deserialize)]
  3. struct BasicAuth{
  4. symbol: String,
  5. faction: String
  6. }
  7. #[derive(Serialize,Deserialize)]
  8. struct Response{
  9. }
  10. #[tokio::main]
  11. async fn main() -> Result<(), reqwest::Error>{
  12. let client = reqwest::Client::new();
  13. let base = BasicAuth{
  14. symbol: "MOP2".to_string(),
  15. faction: "COSMIC".to_string(),
  16. };
  17. let req = client.post("https://api.spacetraders.io/v2/register")
  18. .json(&base)
  19. .send()
  20. .await?;
  21. //println!("{:?}", req.json().await);
  22. let v = serde_json::from_reader(req.json().await.unwrap()).unwrap();
  23. Ok(())
  24. }