• Sends a request to the specified URL.

    Parameters

    • url: string

      The URL to send the request to.

    • method: "GET" | "POST"

      The HTTP method to use ('GET' or 'POST').

    • Optional data: object

      The data to send with the request.

    • Optional token: string

      The authentication token to include in the request headers.

    Returns Promise<any>

    The data from the response.

    Throws

    An error if the request fails.