Decode InvokeCommandOutput.Payload object on "@aws-sdk/client-lambda" package #4020
Unanswered
nightravenjames1994
asked this question in
Q&A
Replies: 1 comment
-
I'm not entirely sure why you are getting this error. I spun up a lambda and got the desired output Client Setup: import { LambdaClient, InvokeCommand } from "@aws-sdk/client-lambda";
const client = new LambdaClient({region: "us-east-1"})
const command = new InvokeCommand({
FunctionName: lambdaName,
InvocationType: 'RequestResponse',
});
try {
const response = await client.send(command);
const payLoad = response.Payload;
if (payLoad != undefined){
const asciiDecoder = new TextDecoder('ascii');
const data = asciiDecoder.decode(response.Payload);
console.log(data)
}
} catch (error) {
console.log(error)
} Output: {
"challenge_name": "CHALLENGE_NAME",
"session": "session string"
} This error is very convoluted and could stem from different issues.
Let me know if that helps. Thanks, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am invoking my lambda function like so in express.JS TypeScript, expecting the following response from my lambda function.
. I did this using the following package https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-lambda/index.html
I've also tried the example on AWS as well as the
toUtf8
andfromUtf8
functions in the SDK to decode the UINT8Array. However, they give me the following error.Beta Was this translation helpful? Give feedback.
All reactions