小编Mar*_*Cox的帖子

NodeJS Lambda 调用错误:无法对响应正文进行字符串化

创建了一个 Lambda 函数以从 AWS Textract API 获取分析。这是相关代码(Node.js 12)

exports.handler = async (event, context, callback) => {
 ...    
 
   let request = textract.getDocumentAnalysis(params);
   request.send((err, data) => {
       if (err) console.log(err, err.stack);
       else console.log(data);
   });
   
    callback(null, request);
}; 
Run Code Online (Sandbox Code Playgroud)

在 CloudWatch 日志中收到此错误:

ERROR   Invoke Error    
{
    "errorType": "Error",
    "errorMessage": "Unable to stringify response body",
    "stack": [
        "Error: Unable to stringify response body",
        "    at _trySerializeResponse (/var/runtime/RAPIDClient.js:175:11)",
        "    at RAPIDClient.postInvocationResponse (/var/runtime/RAPIDClient.js:45:22)",
        "    at complete (/var/runtime/CallbackContext.js:33:12)",
        "    at callback (/var/runtime/CallbackContext.js:43:7)",
        "    at /var/runtime/CallbackContext.js:104:16",
        "    at Runtime.exports.handler …
Run Code Online (Sandbox Code Playgroud)

callback node.js aws-lambda

5
推荐指数
1
解决办法
3859
查看次数

标签 统计

aws-lambda ×1

callback ×1

node.js ×1