feat: added timeout and make visible http error

This commit is contained in:
Sandro Zimmermann 2026-04-23 11:38:50 +02:00
parent 82dbe7f887
commit 15158454f3

View File

@ -2,7 +2,10 @@ import requests
def fetch_user(username: str) -> dict: def fetch_user(username: str) -> dict:
response = requests.get(f"https://www.codewars.com/api/v1/users/{username}") response = requests.get(
f"https://www.codewars.com/api/v1/users/{username}", timeout=5.0
)
response.raise_for_status()
return response.json() return response.json()