debug-request-quth
This commit is contained in:
parent
d15633af0f
commit
e832e57715
15
src/data.rs
15
src/data.rs
|
@ -26,21 +26,29 @@ pub async fn get_auth_id(token: &str) -> Result<i32, Box<dyn Error>> {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
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<String, serde_json::Value> = 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<i32, Box<dyn Error>> {
|
|||
}
|
||||
}
|
||||
} 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()),
|
||||
|
|
Loading…
Reference in New Issue
Block a user