In AWMS Lambda code, how can I get an HTTP method (e.g. GET, POST ...) of an HTTP request coming from the AWS Gateway API?
I understand from the documentation that context.httpMethod is a solution for this.
However, I cannot get it to work.
For example, when I try to add the following 3 lines:
if (context.httpMethod) {
console.log('HTTP method:', context.httpMethod)
}
in the microservice-http-endpoint schema sample AWS as follows:
exports.handler = function(event, context) {
if (context.httpMethod) {
console.log('HTTP method:', context.httpMethod)
}
console.log('Received event:', JSON.stringify(event, null, 2));
};
I never had anything in the log because httpMethod is always empty .
source
share