Interesting Experiments

You will have a firm grasp of​ the concepts discussed in this chapter after performing these interesting experiments!

  • Break the Lambda function for showing the HTML form so it blows up during processing. See how API Gateway handles that kind of situation and check whether you can find the error in the CloudWatch logs.

  • Try wrapping the error into a try/catch block that will return a valid HTTP response explaining the error. For example, use HTTP code 500, reserved for internal server errors. (Hint: you’ll have to modify html-response.js to accept a custom status code.) See how the error report differs from the one when the function just blows up.

  • Try implementing an HTTP redirect from a Lambda function (hint: use code 302 and put a destination URL into the Location header), and then navigate to the API URL from a browser to see the redirect in action.

Get hands-on with 1200+ tech skills courses.