Interface Fetcher

All Superinterfaces:
org.teavm.jso.JSObject

public interface Fetcher extends org.teavm.jso.JSObject
Anything reachable by sending it a request.

Four bindings are this shape and they differ only in what sits on the other end: a service binding reaches another Worker with no network hop and no charge for the subrequest, an assets binding reaches static files, an mTLS binding reaches an origin using a client certificate, and a Browser Rendering binding reaches a headless browser.

Since:
1.0.0
  • Method Details

    • fetch

      default Response fetch(Request request)
      Sends a request.
      Parameters:
      request - the request
      Returns:
      the response
    • fetch

      default Response fetch(String url)
      Sends a GET to a URL.
      Parameters:
      url - the URL
      Returns:
      the response
    • fetch

      default Response fetch(String url, TSObject options)
      Sends a request built from a URL and options.
      Parameters:
      url - the URL
      options - method, headers, body
      Returns:
      the response
    • rpc

      default TSObject rpc(String method, TSObject... args)
      Calls a method the other side exposes over RPC.

      Only meaningful for a service binding whose target extends Cloudflare's WorkerEntrypoint.

      Parameters:
      method - the method name
      args - the arguments
      Returns:
      what the method returned
    • send

      org.teavm.jso.core.JSPromise<Response> send(Request request)
    • send

      org.teavm.jso.core.JSPromise<Response> send(String url)
    • send

      org.teavm.jso.core.JSPromise<Response> send(String url, TSObject options)