Skip to main content

redeemReward

Initiates a request to redeem a reward using spendingRuleId. rewardTemplateId is required to specify the reward template to be redeemed. pointsToSpend is required to specify the number of points to spend for all rules.

Usage example​

Before call a request, ensure the SDK and the Rewards module are ready:

function onSdkReady() {
const moduleName = window.gw.sdk.common.constants.modules.REWARDS;

window.gw.sdk.runIfModuleReady(moduleName, () => {
window.gw.sdk.rewards.methods
.redeemReward(params)
.then(console.log)
.catch(console.error);
});
}

if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}

This code ensures that the SDK and the Rewards module are ready before attempting to call a request. The method will either succeed, returning a success result, or fail, returning an error with details about what went wrong.