headless-loyalty-page-client
Interfaces
HeadlessLoyaltyPageClientOptions
Options for createHeadlessLoyaltyPageClient.
Properties
apiUrl
apiUrl: string;Base URL of the Headless API, e.g. https://api.joy.so/app/api/v1/headless.
fetch?
fetch?: {
(input, init?): Promise<Response>;
(input, init?): Promise<Response>;
(input, init?): Promise<Response>;
};Override fetch (tests, or a runtime with no global fetch). Defaults to globalThis.fetch.
Call Signature
(input, init?): Promise<Response>;MDN Reference (opens in a new tab)
Parameters
| Parameter | Type |
|---|---|
input | RequestInfo | URL |
init? | RequestInit |
Returns
Promise<Response>
Call Signature
(input, init?): Promise<Response>;MDN Reference (opens in a new tab)
Parameters
| Parameter | Type |
|---|---|
input | RequestInfo | URL |
init? | RequestInit |
Returns
Promise<Response>
Call Signature
(input, init?): Promise<Response>;MDN Reference (opens in a new tab)
Parameters
| Parameter | Type |
|---|---|
input | string | Request | URL |
init? | RequestInit |
Returns
Promise<Response>
locale?
locale?: string;The shopper's locale (e.g. fr), sent as ?locale= on the home read so
its primaryTranslation is served in that language. Omit for the shop's
primary language.
openUrl?
openUrl?: (url) => unknown;Opens url in a new tab and returns the opened handle (falsy when the
browser blocked it) — what handleEarningProgram uses for social,
survey and visit-page programs. Defaults to the browser's global open
when there is one.
Parameters
| Parameter | Type |
|---|---|
url | string |
Returns
unknown
shop
shop: string;The shop's myshopify domain (e.g. my-store.myshopify.com). Sent as
?shop= on the public (auth:false) routes that cannot read the shop
from a customer JWT.
Methods
getToken()
getToken():
| string
| Promise<string | null | undefined>
| null
| undefined;Returns the current customer JWT, or null/undefined for a guest.
Called before every authenticated request — no caching here.
Returns
| string
| Promise<string | null | undefined>
| null
| undefined
Functions
createHeadlessLoyaltyPageClient()
function createHeadlessLoyaltyPageClient(options): LoyaltyPageDataClient;Create a LoyaltyPageDataClient over the /headless/* routes.
LoyaltyPageDataClient.accountInvite rejects immediately: no
/headless/* route exists for POST /popup/accountInvite (opt-in
linkAccounts section only). LoyaltyPageDataClient.get/
LoyaltyPageDataClient.post refuse a path outside their explicit map
rather than forwarding it — never an open proxy onto /headless/*.
Parameters
| Parameter | Type |
|---|---|
options | HeadlessLoyaltyPageClientOptions |