Skip to main content

Posts

Showing posts with the label LAMBDA

Getting to know the Lambda Event Object

With any kind of http request, being it a simple web server or an api gateway, we will usually need to log different kind of information regarding the received request. But how can we do that with Lambda and how can we get all available information from it? Thats when the event object comes in place. The API GATEWAY will send all information about the request encapsulated in the event object passing it as an argument to our lambda function, like this: exports.handler = (event, context, callback) => { }; The event object have the following nested objects as shown below: 1. resource 2. path 3. httpMethod 4. headers 5. multiValueHeaders 6. queryStringParameters 7. multiValueQueryStringParameters 8. pathParameters 9. stageVariables 10. requestContext 11. body 12. isBase64Encoded { "resource": "/", "path": "/", "httpMethod": "GET", "headers": {}, "multiValueHe...

API Gateway Integration with Lambda : How to get all querystrings params

If you stringify the event you will notice that the queryStringParameters is actually an object rather than an array. So in order to get all queryStrings params passed in an API Gateway request you can simply make a for each key value pair in the object like this: var element = {}; for (var key in event.queryStringParameters) { element[key] = event.queryStringParameters[key]; }