Bird
0
0

Which of the following is the correct syntax to define a Node.js AWS Lambda handler function?

easy📝 Syntax Q3 of 15
AWS - Lambda
Which of the following is the correct syntax to define a Node.js AWS Lambda handler function?
Aexports.handler = async (event) => { return 'Hello'; };
Bfunction handler(event) { return 'Hello'; }
Cmodule.exports = function(event) { return 'Hello'; }
Dlambda.handler = function(event) { return 'Hello'; }
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct Lambda handler export syntax

    In Node.js Lambda, the handler is exported as 'exports.handler' and can be async.
  2. Step 2: Check other options for correctness

    function handler(event) { return 'Hello'; } is a function but not exported. module.exports = function(event) { return 'Hello'; } exports a function but not as 'handler'. lambda.handler = function(event) { return 'Hello'; } uses an undefined 'lambda' object.
  3. Final Answer:

    exports.handler = async (event) => { return 'Hello'; }; -> Option A
  4. Quick Check:

    Node.js Lambda handler syntax = exports.handler [OK]
Quick Trick: Use exports.handler for Node.js Lambda functions [OK]
Common Mistakes:
  • Not exporting the handler function
  • Using incorrect export syntax
  • Assuming 'lambda' object exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes