Scala.js web client
Web client using XMLHttpRequest
.
The Endpoints
interpreter fixes the type Endpoint[A, B]
to a function from A
to Result[B]
, where Result
is abstract and is intended to be defined by more specialized interpreters.
An example of such an interpreter is endpoints4s.xhr.client.future.Endpoints
, which fixes the Result[A]
type to scala.concurrent.Future[A]
.
This means that, given the following endpoint definition:
val someResource: Endpoint[Int, String] =
endpoint(get(path / "some-resource" / segment[Int]()), ok(textResponse))
It can be invoked as follows:
val eventuallyString: Future[String] = someResource(42)
Another example is endpoints4s.xhr.client.faithful.Endpoints
, which fixes the Result[A]
type to faithful.Future[A]
. This interpreter requires an additional dependency (which, in turn, depends on the faithful library):
1.2.0