[Node.js] Invoke Lambda with AWS SDK for JavaScript v3
Created on November 28, 2026
You can invoke a Lambda function by combining LambdaClient and InvokeCommand from @aws-sdk/client-lambda. This example invokes the dummy-function-name Lambda function synchronously with the RequestResponse invocation type.
const { LambdaClient, InvokeCommand } = require("@aws-sdk/client-lambda");
async function main() {
const lambdaClient = new LambdaClient({ region: "ap-northeast-1" });
const invokeCommand = new InvokeCommand({
FunctionName: "dummy-function-name",
InvocationType: "RequestResponse",
});
const response = await lambdaClient.send(invokeCommand);
console.log(response);
}
main();
The following is an example of the output.
{
'$metadata': {
httpStatusCode: 200,
requestId: '5d1de5a9-a3f3-4ac7-9966-8f820f717b0c',
extendedRequestId: undefined,
cfId: undefined,
attempts: 1,
totalRetryDelay: 0
},
ExecutedVersion: '$LATEST',
Payload: Uint8Array(13) [
34, 72, 101, 108, 108,
111, 32, 87, 111, 114,
108, 100, 34
],
StatusCode: 200
}
To convert Payload to a string, use an expression such as new TextDecoder().decode(response.Payload). The result is the following string.
"Hello World"