Courseiva
User Interface →hardMultiple Choice

SF-PD2 User Interface Practice Question

A developer is building a Lightning Web Component that must call an Apex method that performs a callout. The component is placed on a Lightning record page, and the Apex method is annotated with @AuraEnabled(cacheable=true). Users report that the callout never executes and an error is thrown. What is the most likely cause and the correct fix?

⚠ Common exam trap

The trap here is assuming that cacheable=true is always beneficial for performance, when it actually forbids callouts and DML in the method body.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

The callout is blocked because @AuraEnabled(cacheable=true) methods cannot perform callouts; remove cacheable=true or move the callout to a method without caching.

Apex methods annotated with @AuraEnabled(cacheable=true) run in a read-only context that prohibits callouts and DML. When such a method attempts a callout, Salesforce throws an error before the callout is made. The correct resolution is to remove cacheable=true or to move the callout into a separate non-cacheable method that the component invokes directly, allowing the callout to proceed while keeping any cacheable read logic separate.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    The callout is blocked by the component's Lightning locker service; disable locker service for the component in Setup.

    Why it's wrong here

    Lightning Locker is a security architecture that isolates component code but does not block Apex callouts from Apex methods. Locker service cannot be disabled per component in Setup, and doing so would not address the cacheable method restriction. The root cause is the annotation, not the client-side security framework, so this option misidentifies the problem.

  • ✗

    The error occurs because the Apex method must be annotated with @AuraEnabled(cacheable=true) to allow callouts; add the annotation.

    Why it's wrong here

    Adding cacheable=true would make the situation worse, since cacheable methods are precisely the ones that cannot perform callouts. The annotation is intended for read-only data retrieval that can be cached on the client. This option reverses the actual rule and would not resolve the error, making it an incorrect fix.

  • ✗

    The callout fails because Lightning Web Components cannot call Apex methods that perform callouts; use a Visualforce remoting call instead.

    Why it's wrong here

    Lightning Web Components can call Apex methods that perform callouts when the method is properly annotated and the org has a remote site setting or named credential configured. The limitation is not the LWC platform itself but the cacheable annotation. Visualforce remoting is not required and would introduce unnecessary complexity, so this diagnosis is incorrect.

  • ✓

    The callout is blocked because @AuraEnabled(cacheable=true) methods cannot perform callouts; remove cacheable=true or move the callout to a method without caching.

    Why this is correct

    Methods marked with @AuraEnabled(cacheable=true) are executed in a read-only context and are subject to restrictions that prevent DML and callouts. Attempting a callout from a cacheable method throws an error. Removing cacheable=true or separating the callout into a non-cacheable method allows the callout to execute, though it loses the client-side caching benefit.

About these practice questions

This SF-PD2 question is part of Courseiva's 226-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Salesforce exam blueprint

This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.