Retrieves the loyalty coupons for the currently logged-in member.
function getCurrentMemberCoupons(): Promise<GetCurrentMemberCouponsResponse>;
import { coupons } from "wix-loyalty.v2";
import { webMethod, Permissions } from "wix-web-module";
export const getCurrentMemberCoupons = webMethod(
Permissions.Anyone,
async () => {
try {
const result = await coupons.getCurrentMemberCoupons();
return result;
} catch (error) {
console.error(error);
// Handle the error
}
},
);
/* Promise resolves to:
*
* {
* "loyaltyCoupons": [
* {
* "_createdDate": "2024-06-12T08:14:16.884Z",
* "_id": "6fb2cdc0-863f-4b4b-b76d-a73608654aee",
* "_updatedDate": "2024-06-12T08:14:17.403Z",
* "couponReference": {
* "code": "6QLGLVTGVH8A",
* "couponId": "27d5d44d-eb61-4533-8f72-01177097e470",
* "name": "10% off all events",
* "specification": {
* "type": "PERCENT_OFF_RATE",
* "percentOffRate": 10,
* "scope": {
* "name": "ticket",
* "namespace": "events"
* },
* "limitedToOneItem": false
* }
* },
* "memberId": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
* "memberIdDeprecated": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
* "revision": "2",
* "rewardName": "10% off all events",
* "status": "ACTIVE",
* "transactionId": "0b24afeb-2964-4bb2-a5ab-b32e04128c20",
* "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303"
* }
* ]
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.