Salesforce Platform Developer I (legacy) — Question 200
A developer wrote an Apex method to update a list of Contacts and wants to make it available for use by Lightning web components.
Which annotation should a developer add to the Apex method to archive this?
Answer options
- A. @RemoteAction(cacheable=true)
- B. @AuraEnabled
- C. @RemoteAction
- D. @AuraEnabled(cacheable=true)
Correct answer: D
Explanation
The correct answer is D, as the @AuraEnabled annotation makes the Apex method accessible to Lightning components, and the (cacheable=true) allows for caching of the method's response, optimizing performance. Options A and C are incorrect because they do not properly enable the method for Lightning web components, and option B lacks the caching capability.