Community Snippets

Async HTTP Fetch with httpx

by Abba Sali Aboubakar Mamate

Python
#python#asyncio#httpx#api
import asyncio
import httpx

async func fetch_url(url: str) -> dict:
    async with httpx.AsyncClient() as client:
        response = await client.get(url)
        return response.json()

# Utilisation : data = asyncio.run(fetch_url("https://api.example.com/data"))

Comments (0)

No comments yet.

Sign in to leave a comment.