Module Fetchify.CreateFetchImplementation

Parameters

Signature

type 'a promise
type ('a, 'error) result
module Status : module type of Status
module Headers : module type of Headers
module Request : module type of Request
module Method : module type of Method
module Body : sig ... end
module Response : sig ... end
val fetch : ?⁠body:string -> ?⁠headers:Headers.t list -> ?⁠meth:Method.t -> string -> (Response.t, string) result promise

Make a fetch-request with a body (optional), headers (optional), method (defaults to * `GET) to endpoint url.

Examples

Fetch.fetch("https://example.com")
Fetch.fetch(
  "https://example.com",
  ~body="Some, body",
  ~headers=[("Authorization", "Bearer xyz")],
  ~meth=`POST)
val get : ?⁠body:string -> ?⁠headers:Headers.t list -> string -> (Response.t, string) result promise

Make a GET-request with a body (optional), headers (optional) to endpoint url.

Examples

Fetch.get("https://example.com")
Fetch.get(
  "https://example.com",
  ~headers=[("Authorization", "Bearer xyz")],
)
val post : ?⁠body:string -> ?⁠headers:Headers.t list -> string -> (Response.t, string) result promise

Make a POST-request with a body (optional), headers (optional) to endpoint url.

Examples

Fetch.post(
  "https://example.com",
  ~body="Some, body",
  ~headers=[("Authorization", "Bearer xyz")],
)
val put : ?⁠body:string -> ?⁠headers:Headers.t list -> string -> (Response.t, string) result promise

Make a PUT-request with a body (optional), headers (optional) to endpoint url.

Examples

Fetch.put(
  "https://example.com/movies/1",
  ~body="Some, body",
  ~headers=[("Authorization", "Bearer xyz")],
)
val delete : ?⁠body:string -> ?⁠headers:Headers.t list -> string -> (Response.t, string) result promise

Make a DELETE-request with a body (optional), headers (optional) to endpoint url.

Examples

Fetch.delete(
  "https://example.com/movies/1",
  ~headers=[("Authorization", "Bearer xyz")],
)