# Having an issue on lambda path parameter using nodejs22

**URL:** <https://forum.ansible.com/t/having-an-issue-on-lambda-path-parameter-using-nodejs22/43640>\
**Category:** Get Help\
**Tags:** aws\
**Created:** [June 30, 2025, 3:42pm UTC](https://forum.ansible.com/t/having-an-issue-on-lambda-path-parameter-using-nodejs22/43640 "2025-06-30T15:42:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pareduane](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pareduane/32/8953_2.png) [@pareduane](https://forum.ansible.com/u/pareduane)\
**Post date:** [June 30, 2025, 3:42pm UTC](https://forum.ansible.com/t/having-an-issue-on-lambda-path-parameter-using-nodejs22/43640/1 "2025-06-30T15:42:59Z")

</div>

I’m creating an API in AWS API gateway.  
Create a DB in DynamoDB and code in Lambda.  
Passing the constant (id: ‘1’) works but does not when used path parameter.  
I’m using nodejs22 web framework.

This is the code:

> //import AWS from “@aws-sdk/lib-dynamodb”;  
> import { DynamoDBClient } from “@aws-sdk/client-dynamodb”;  
> import { DynamoDBDocumentClient, GetCommand } from “@aws-sdk/lib-dynamodb”;
> 
> export const handler = async (event) =\> {  
> // Bare-bones DynamoDB Client  
> const client = new DynamoDBClient({});
> 
> // Bare-bones document client  
> const ddbDocClient = DynamoDBDocumentClient.from(client); // client is DynamoDB client
> 
> // Path parameters  
> const {pizza\_id} = event.pathParameters;
> 
> const params = {  
> TableName: ‘Pizza’,  
> Key: {  
> //id: ‘2’  
> id: pizza\_id  
> }  
> };
> 
> try {  
> const data = await ddbDocClient.send(new GetCommand(params));  
> [//console.log](https://console.log)(“Success”, data.Item);  
> const response = {  
> statusCode: 200,  
> body: JSON.stringify(data.Item),  
> };  
> return response;  
> } catch (err) {  
> console.error(“Error”, err);  
> }
> 
> };

This is the error:

> {  
> “errorType”: “TypeError”,  
> “errorMessage”: “Cannot destructure property ‘pizza\_id’ of ‘event.pathParameters’ as it is undefined.”,  
> “trace”: [  
> “TypeError: Cannot destructure property ‘pizza\_id’ of ‘event.pathParameters’ as it is undefined.”,  
> " at Runtime.handler (file:///var/task/index.mjs:13:10)“,  
> " at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1205:29)”  
> ]  
> }

Thank you in advance (",)

---

<div class="post-metadata">

**Author:** ![pareduane](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pareduane/32/8953_2.png) [@pareduane](https://forum.ansible.com/u/pareduane)\
**Post date:** [June 30, 2025, 6:48pm UTC](https://forum.ansible.com/t/having-an-issue-on-lambda-path-parameter-using-nodejs22/43640/2 "2025-06-30T18:48:17Z")

</div>

Note that this is set on my integration request:

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/4/4fea12422bdfb1160fc9b1cd84e5cecf0bd9e402.png)

---

<div class="post-metadata">

**Author:** ![pareduane](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pareduane/32/8953_2.png) [@pareduane](https://forum.ansible.com/u/pareduane)\
**Post date:** [June 30, 2025, 7:23pm UTC](https://forum.ansible.com/t/having-an-issue-on-lambda-path-parameter-using-nodejs22/43640/3 "2025-06-30T19:23:23Z")

</div>

Got it!  
The test in lambda will always return undefined.  
Never test this in lambda.  
I tested it by sending the HTTP request.

---

<div class="post-metadata">

**Author:** ![anon81884396](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anon81884396](https://forum.ansible.com/u/anon81884396)\
**Post date:** [June 30, 2025, 9:25pm UTC](https://forum.ansible.com/t/having-an-issue-on-lambda-path-parameter-using-nodejs22/43640/4 "2025-06-30T21:25:38Z")

</div>

I think you are confusing AWX for AWS.
