我正在使用
api gateway
把邮寄请求打到我的邮箱里
lambda
检查
httpMethod is post
index.js
但我想如果我用的是同样的
λ
,我也可以检查它是否是
get httpMethod
,如果是,则执行以下操作。但我想分开我的密码。我也看到了
λ
post.js
不知何故,它没有传递值或调用中的导出函数
邮政.js
不过。
索引.js
const postHandler = require('./post.js');
exports.handler = async (event, context) => {
try {
const httpm = event.context["http-method"];
const rbody = event["body-json"];
console.log(postHandler, 'post handler function?'); // { postHandler: [AsyncFunction] } 'post handler function?'
console.log(httpm, 'httpmhttpm'); // 'POST'
if (httpm === 'POST') return postHandler(rbody);
} catch (e) {
return e;
}
};
邮政.js
exports.postHandler = async (rbody) => {
console.log('I am inside postHandler()');
console.log(rbody);
return {status: true};
};
提前感谢您的建议/帮助。