Let's take a look at this example method:
GetCustomerWithPoints(customerId: number): Customer {
const customer = this.customerService.getCustomer(customerId);
const points = this.pointService.getPointsForCustomer(customerId);
return {...customer, [customer.rewards.points]: points };
}
What should we do when customer.rewards
is either null
or undefined
? Should the points only be set if the rewards
object actually exists?
An issue I'm encountering with this code is the error message saying Object is possibly 'undefined'
.