gleam add rsvp@1Rsvp helps you make HTTP requests and handle their responses in a Lustre application. This library supports both client side SPAs and components, and server components meaning applications that use rsvp are more likely to be suitable as universal components.
Rsvp separates the concerns of making HTTP requests from handling their responses meaning we need to do three things to properly make a request:
-
First, we must define a
Handlerthat describes how to handler the response and turn it into a message yourupdatefunction can understand. -
Second, we must create the
Effectthat describes the request using either thegetorpostconvenience functions, or by constructing aRequestand usingsenddirectly. -
Finally, we must return that
Effectin our application'sinitorupdatefunctions so that the runtime can perform the request.
The following recipes are available to help you get started with rsvp:
If you think a common use case is missing or you'd like to contribute a recipe yourself, please open an issue or pull request!