如何解决使用节点 js 格式从 AWS lambda 发送 Json 数据
现在我设置了由 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 举报,一经查实,本站将立刻删除。