Scala.js web client (XHR)
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:
sourceval someResource: Endpoint[Int, String] =
endpoint(get(path / "some-resource" / segment[Int]()), ok(textResponse))
It can be invoked as follows:
sourceval eventuallyString: Future[String] = someResource(42).future
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):
5.3.0