diff --git a/src/data.rs b/src/data.rs index fc1fc66..80dfc5b 100644 --- a/src/data.rs +++ b/src/data.rs @@ -26,21 +26,29 @@ pub async fn get_auth_id(token: &str) -> Result> { } } }); - + println!("GraphQL Request: {:?}", gql); let client = HTTPClient::new(); let response = client .post(&auth_api_base) .headers(headers) .json(&gql) .send() - .await?; + .await; + + let response = match response { + Ok(res) => res, + Err(err) => { + println!("Error sending request: {:?}", err); + return Err(Box::new(err)); + } + }; if response.status().is_success() { let r: HashMap = response.json().await?; let user_id = r .get("data") .and_then(|data| data.get("validate_jwt_token")) - .and_then(|query| query.get("clams")) + .and_then(|query| query.get("claims")) .and_then(|claims| claims.get("sub")) .and_then(|id| id.as_i64()); @@ -58,7 +66,6 @@ pub async fn get_auth_id(token: &str) -> Result> { } } } else { - println!("Request failed with status: {}", response.status()); Err(Box::new(std::io::Error::new( std::io::ErrorKind::Other, format!("Request failed with status: {}", response.status()),