Skip to content

Latest commit

 

History

History
29 lines (18 loc) · 694 Bytes

async_client.rst

File metadata and controls

29 lines (18 loc) · 694 Bytes

Using async_client

The @async_client decorator lets you make non-blocking HTTP requests.

from dequest import async_client

@async_client(url="https://api.example.com/notify", method="POST")
def notify():
    pass

notify()  # Fire-and-forget call

Using Callbacks

If you need to handle the response asynchronously, use a callback function. Callbacks let you process API responses asynchronously.

async def process_response(data):
    print("Received:", data)

@async_client(url="https://api.example.com/updates", callback=process_response)
def fetch_updates():
    pass