GeoLeaf Core API - v3.0.0
    Preparing search index...
    • Runs fetch with a deadline, and turns an abandonment into a NAMED error.

      Parameters

      • url: string

        Request URL.

      • init: RequestInit = {}

        Standard RequestInit. Any signal it carries is honoured in addition to the deadline: the request aborts on whichever fires first.

      • timeoutMs: number = DEFAULT_FETCH_TIMEOUT_MS

        Deadline in milliseconds. Defaults to DEFAULT_FETCH_TIMEOUT_MS.

      Returns Promise<Response>

      The Response, whatever its status — a 404 is an answer, not an abandonment.

      kind: "timeout" when the deadline fired, "network" otherwise.

      try {
      const res = await fetchBounded(url, { method: "HEAD" }, 5000);
      } catch (err) {
      if (err instanceof BoundedFetchError && err.kind === "timeout") {
      // dire à l'utilisateur que le serveur n'a pas répondu, pas que la ressource manque
      }
      }