diff --git a/src/entitlement-sqs.js b/src/entitlement-sqs.js index 20199f2..55c92f8 100644 --- a/src/entitlement-sqs.js +++ b/src/entitlement-sqs.js @@ -25,7 +25,8 @@ exports.handler = async (event) => { console.log('entitlementsResponse', entitlementsResponse); - const isExpired = new Date(entitlementsResponse.Entitlements[0].ExpirationDate) < new Date(); + const isExpired = entitlementsResponse.hasOwnProperty("Entitlements") === false || entitlementsResponse.Entitlements.length === 0 || + new Date(entitlementsResponse.Entitlements[0].ExpirationDate) < new Date(); const dynamoDbParams = { TableName: newSubscribersTableName,