Bird
0
0

Given this Lambda function code triggered by API Gateway, what will be the response body?

medium📝 Predict Output Q4 of 15
AWS - API Gateway
Given this Lambda function code triggered by API Gateway, what will be the response body?
exports.handler = async (event) => { return { statusCode: 200, body: JSON.stringify({ message: 'Hello ' + event.queryStringParameters.name }) }; };
API Gateway is called with URL: /?name=Alice
A{"message":"Hello Alice"}
B{"message":"Hello undefined"}
CError: Missing name parameter
D{"message":"Hello"}
Step-by-Step Solution
Solution:
  1. Step 1: Analyze event input

    event.queryStringParameters.name is 'Alice' from URL query.
  2. Step 2: Check returned body

    Function returns JSON string with message 'Hello Alice'.
  3. Final Answer:

    {"message":"Hello Alice"} -> Option A
  4. Quick Check:

    Query param passed correctly = {"message":"Hello Alice"} [OK]
Quick Trick: Query parameters appear in event.queryStringParameters [OK]
Common Mistakes:
  • Assuming missing parameters cause error
  • Not stringifying JSON body
  • Ignoring query parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes