Skip to main content

fetch_json

Function fetch_json 

Source
pub async fn fetch_json<T: DeserializeOwned>(
    client: &Client,
    url: &str,
) -> Result<T, String>
Expand description

GET url, check HTTP status, parse body as JSON.

Retries up to MAX_RETRIES times on network errors or 5xx/429 responses, with exponential backoff starting at INITIAL_BACKOFF_MS.

Returns a descriptive error that always includes the URL, HTTP status, attempt count, and a body preview when JSON parsing fails.