CCD-102 practice question 10 of 30
Given the code snippet aboce, what should be added after this code so it can be used for page component display?
Full set: 206 questionsIn the context of the Salesforce B2C Commerce Storefront Reference Architecture (SFRA), controllers are used to handle requests and render page components. The server module is used to define endpoints or routes. After defining all necessary routes (such as a Render route for a component), the line module.exports = server.exports(); is required. This statement exports all the defined routes as a single module object, making them accessible to the B2C Commerce framework to be called for processing requests and displaying content on a page. This is the standard and mandatory pattern for exposing controller functionality.
1. Salesforce B2C Commerce Developer Documentation, "Controllers in SFRA": This official documentation explicitly states the requirement for exporting controller functionality. It details that after routes are appended to the server object using methods like server.get, the module must conclude with module.exports = server.exports(); to make the routes available to the system. (Refer to the "How to Build a Controller" section).
2. Salesforce Trailhead, "Salesforce B2C Commerce for Developers" Trail, "Controllers and Routes in SFRA" Module: This official training material demonstrates the creation of controllers. In every example, after defining routes with server.get, server.post, or server.append, the final line of the file is module.exports = server.exports();. This reinforces it as the required pattern for a controller to function.
3. Salesforce B2C Commerce Developer Center, "SFRA Architecture": The architectural overview of SFRA explains that controllers are based on a modular, event-driven architecture. The server.exports() pattern is the mechanism that plugs the custom controller logic into this event-handling system, allowing it to respond to storefront requests.
Keep practicing
Take the free CCD-102 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other CCD-102 practice questions
- Question 1A developer has a sandbox with code to log a message during execution, and the following …
- Question 3Server.get(‘Show’, consentTracking.consent, cache.applyDefaultCache, function (req,res,ne…
- Question 4A developer needs to update the package.json file so that it points to the hock file for …
- Question 5A developer wants to create in Business Manager extension with the cartridge named plugin…
- Question 6A client uses tax tables in Business Manager to calculate tax. They recently started ship…
- Question 7A Digital Developer has a site export file on their computer that needs to be imported in…
