API (window.lantern.api)
The window.lantern.api object is your primary tool for communicating with the Lantern backend from the storefront. It provides a set of methods to perform actions and fetch data, with authentication handled automatically.
Available Methods
Theapi object comes pre-configured with several methods tailored for common storefront operations.
| Method | Description |
|---|---|
getAccountActivity | Fetches the user’s account activity feed. |
updateProfile | Updates the user’s profile information. |
Usage Example
All API methods are asynchronous and return aPromise. You should use async/await or .then() to handle the response.
Here’s an example of how to fetch the current user’s account activity.
Authentication
You do not need to handle authentication headers or tokens manually. Thewindow.lantern.api client automatically manages the user’s session. When a user is logged into their Shopify account, the API client sends authenticated requests on their behalf. If the user is not logged in, the API will behave as an unauthenticated user.