From 62a2820af323e131825564a18697b62ad7ed0259 Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Sat, 19 Oct 2024 22:23:51 +0800 Subject: [PATCH] add params support in fetch_json --- utils/net.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/net.py b/utils/net.py index 623c6ed..fe487a5 100644 --- a/utils/net.py +++ b/utils/net.py @@ -11,8 +11,8 @@ async def close_client(_client: AsyncClient) -> None: return await _client.aclose() -async def fetch_json(_client: AsyncClient, url: str) -> dict: - response = await _client.get(url) +async def fetch_json(_client: AsyncClient, url: str, params: dict = None) -> dict: + response = await _client.get(url, params=params) assert response.is_success, f"Failed to fetch {url}, status code {response.status_code}" return response.json() @@ -33,5 +33,5 @@ class NetClient: return cls._httpx_client @classmethod - async def fetch_json(cls, url: str) -> dict: - return await fetch_json(cls._httpx_client, url) + async def fetch_json(cls, url: str, params: dict = None) -> dict: + return await fetch_json(cls._httpx_client, url, params)