I am trying to find a specific loyalty coupon by its user-inputted confirmation code. I’ve made some minor modifications here, but even the unedited sample backend code from the Wix documentation shows the same error and will not run.
import { coupons } from "wix-loyalty.v2";
import { webMethod, Permissions } from "wix-web-module";
import { elevate } from "wix-auth";
const elevatedQueryLoyaltyCoupons = elevate(coupons.queryLoyaltyCoupons);
export const queryLoyaltyCouponByCode = webMethod(
Permissions.Anyone,
async (confirmationCode) => {
try {
// Build the query to filter by coupon reference code
const query = {
fieldsets: [],
fields: [],
sort: [],
filter: {
"couponReference.code": {
"$eq": confirmationCode
}
}
};
const result = await elevatedQueryLoyaltyCoupons(query); //ERROR APPEARS HERE
return result;
} catch (error) {
console.error('Error querying loyalty coupon:', error);
throw error;
}
}
);
The API documentation including sample code can be found here.
The code will not run. There’s a red squiggly error marker under the word query with the message: " ‘await’ has no effect on the type of this expression. Expected 0 arguments, but got 1. "
Seems odd that even the Wix sample code has this error.
(Loyalty app installed and have had no problems with other API functions.)