问题描述
现在我设置了由 SQS 触发的 AWS lambda 系统。我设置了 lambda 使用 nodejs 格式。我很难从 SQS 发送正文消息并发回我的 https 网址。
这是我的代码
const https = require('https')
const data = new TextEncoder().encode(
JSON.stringify({
data: 'datasend'
})
)
const options = {
hostname: '<my url>',port: 443,method: 'POST',headers: {
'Content-Type': 'application/json','Content-Length': data.length
}
}
const req = https.request(options,res => {
console.log(`statusCode: ${res.statusCode}`)
res.on('data',d => {
process.stdout.write(d)
})
})
req.on('error',error => {
console.error(error)
})
req.write(data)
req.end()
但它返回错误
2021-07-15T01:48:35.566Z undefined ERROR Uncaught Exception {
"errorType": "Runtime.HandlerNotFound","errorMessage": "index.handler is undefined or not exported","stack": [
"Runtime.HandlerNotFound: index.handler is undefined or not exported"," at Object.module.exports.load (/var/runtime/UserFunction.js:144:11)"," at Object.<anonymous> (/var/runtime/index.js:43:30)"," at Module._compile (internal/modules/cjs/loader.js:999:30)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)"," at Module.load (internal/modules/cjs/loader.js:863:32)"," at Function.Module._load (internal/modules/cjs/loader.js:708:14)"," at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)"," at internal/main/run_main_module.js:17:47"
]
}
请帮忙
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)