From 79209bc550ee1b0356566d156c0d1a20e1aad3fa Mon Sep 17 00:00:00 2001 From: wengcan Date: Thu, 1 Apr 2021 23:23:45 +0800 Subject: [PATCH] update the way to get event method event.httpMethod always returns null , so update this mthod to : event.requestContext.http.method --- src/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 443d735..b9890c6 100644 --- a/src/index.js +++ b/src/index.js @@ -7,7 +7,10 @@ const TABLE_NAME = process.env.TABLE_NAME, IS_CORS = true; exports.handler = async event => { - if (event.httpMethod === 'OPTIONS') { + + const method = event.requestContext.http.method; + + if (method === 'OPTIONS') { return processResponse(IS_CORS); } if (!event.body) {