• Retrieves and sorts endpoints by their health status.

    Parameters

    Returns Promise<{ address: string; responseTime: number | null }[]>

    A promise that resolves to an array of endpoints sorted by response time.

    import { NETWORK_TYPE, ENDPOINT_TYPE, getEndpointsSorted } from "@akashnetwork/akashjs/build/network";

    const displaySortedEndpoints = async () => {
    try {
    const endpoints = await getEndpointsSorted(NETWORK_TYPE.MAINNET, ENDPOINT_TYPE.RPC);
    console.log("Sorted Endpoints:", JSON.stringify(endpoints, null, 2));
    } catch (error) {
    console.error("Error fetching sorted endpoints:", error);
    }
    };

    displaySortedEndpoints();