Kaynağa Gözat

Authentification working, need to retrieve data in json format

Clemsim 1 yıl önce
ebeveyn
işleme
f89439ad70
1 değiştirilmiş dosya ile 27 ekleme ve 2 silme
  1. 27 2
      src/main.rs

+ 27 - 2
src/main.rs

@@ -1,3 +1,28 @@
-fn main() {
-    println!("Hello, world!");
+use serde::{Deserialize, Serialize};
+
+#[derive(Serialize,Deserialize)]
+struct BasicAuth{
+    symbol: String,
+    faction: String
+}
+
+#[derive(Serialize,Deserialize)]
+struct Response{
+
+}
+#[tokio::main]
+async fn main() -> Result<(), reqwest::Error>{
+    let client = reqwest::Client::new();
+    let base = BasicAuth{
+        symbol: "MOP2".to_string(),
+        faction: "COSMIC".to_string(),
+    };
+    let req = client.post("https://api.spacetraders.io/v2/register")
+    .json(&base)
+    .send()
+    .await?;
+    //println!("{:?}", req.json().await);
+
+    let v = serde_json::from_reader(req.json().await.unwrap()).unwrap();
+    Ok(())
 }