We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Aiohttp client.
import asyncio import logging from aiohttp import ClientSession from jsonrpcclient import Error, Ok, parse, request async def main() -> None: """Handle async request""" async with ClientSession() as session: async with session.post( "http://localhost:5000", json=request("ping") ) as response: parsed = parse(await response.json()) # In Python 3.10+ use `match` syntax here instead of isinstance if isinstance(parsed, Ok): print(parsed.result) elif isinstance(parsed, Error): logging.error(parsed.message) asyncio.get_event_loop().run_until_complete(main())
Reference: JSON-RPC in aiohttp.