Created a Lambda function to get analysis from AWS Textract API. Here is the relevant code (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);
};
In CloudWatch logs get this error:
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 (/var/task/index.js:92:5)",
" at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
]
}
When I modify the callback: callback(null, request.X) ... lambda returns the data object from Textract. I at first thought that I had to drill down into the data object (request.DocumentMetadata) ... but works with any string of characters I put in front of "request." (at least the ones I've tried). Any help with this is appreciated.