Scala.js web client
Web client using XMLHttpRequest.
"org.julienrf" %%% "endpoints-xhr-client" % "0.15.0"
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 endpoints.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 endpoints.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):
// Provides endpoints.xhr.client.faithful.Endpoints
"org.julienrf" %%% "endpoints-xhr-client-faithful" % "0.15.0"
0.15.0