Retrieves the site's loyalty program.
The getLoyaltyProgram()
function returns a Promise that resolves to the site's loyalty program.
function getLoyaltyProgram(): Promise<GetLoyaltyProgramResponse>;
import { programs } from "wix-loyalty.v2";
export async function myGetLoyaltyProgramFunction() {
try {
const myLoyaltyProgram = await programs.getLoyaltyProgram();
const name = myLoyaltyProgram.loyaltyProgram.name;
const status = myLoyaltyProgram.loyaltyProgram.status;
console.log("Success! The status of your loyalty program is:", status);
return myLoyaltyProgram;
} catch (error) {
console.error(error);
}
}
/* Promise resolves to:
* {
* "loyaltyProgram": {
* "name": "Frequent Flower Program",
* "pointDefinition": {
* "customName": "Petals",
* "icon": "shapes/8de38e8fe76f4e9f937ae23e9ba1eb04.svg"
* },
* "status": "ACTIVE",
* "_createdDate": "2022-11-07T15:26:12.798Z",
* "_updatedDate": "2022-11-09T10:00:42.018Z"
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.