Fix user_data_context function to handle missing

api_key
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-11-13 14:53:40 -03:00
commit afe9c9d1f4

View file

@ -30,6 +30,7 @@ user_data_var: ContextVar[Optional[Dict[str, Any]]] = ContextVar(
def user_data_context(store_service: "StoreService", api_key: Optional[str] = None):
# Fetch and set user data to the context variable
if api_key:
user_data = None
try:
user_data = store_service._get(
f"{store_service.base_url}/users/me", api_key, params={"fields": "id"}