From 22f2b0692de4f9177400e538b99acecf7890a745 Mon Sep 17 00:00:00 2001 From: Callum Silcock Date: Fri, 21 Oct 2016 11:31:29 +1100 Subject: [PATCH] Update api-gateway.md docs to include note about parsing JSON event body As per title, just wasted some time on this as it wasn't obvious, thought a note could save some time in future Stole language from the [lambda-proxy npm module](https://www.npmjs.com/package/lambda-proxy) --- docs/02-providers/aws/events/01-apigateway.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/02-providers/aws/events/01-apigateway.md b/docs/02-providers/aws/events/01-apigateway.md index 501cb4329..1bf5f1444 100644 --- a/docs/02-providers/aws/events/01-apigateway.md +++ b/docs/02-providers/aws/events/01-apigateway.md @@ -133,6 +133,11 @@ exports.handler = function(event, context, callback) { }; ``` +**Note:** When the body is a JSON-Document, you must parse it yourself: +``` +JSON.parse(event.body); +``` + **Note:** If you want to use CORS with the lambda-proxy integration, remember to include `Access-Control-Allow-Origin` in your returned headers object. Take a look at the [AWS documentation](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-lambda.html)