aws-samples / aws-samples/aws-dynamodb-examples
batchGet method not working
- Dominant language
- TypeScript
- Stars
- 602
- Forks
- 242
- Avg merge
- 14m
- Merged PRs (30d)
- 2
Description
Hi Team,
I have trying to get batch of record. But I'm unable to fetch the record and getting the below error and code.
Please help on that issue.
My Below code
import AWS, { DynamoDB } from 'aws-sdk';
const docClient = new AWS.DynamoDB.DocumentClient();
const keyMap = await custIDs.map((element: any) => {
return { customerId: element.mergeCustId.toString(), vehicleId: element.mergeCustId.toString() };
});
console.log("keyMap", JSON.stringify(keyMap));
const params = {
RequestItems: {
'eos-dev-Customer-Vehicles': {
Key: keyMap,
}
}
};
console.log("params", JSON.stringify(params));
return docClient.batchGet(keyMap, (err: any, data: any) => {
if (err) {
console.log("err", err);
} else { console.log("data", data); }
});
Error:
2023-07-11T10:39:32.993Z a89ddd1c-c372-468c-a9d2-a91173ab9a82 INFO err MissingRequiredParameter: Missing required key 'RequestItems' in params
at ParamValidator.fail (/var/task/output/purge-merge-automation/index.js:22005:37)
at ParamValidator.validateStructure (/var/task/output/purge-merge-automation/index.js:22016:14)
at ParamValidator.validateMember (/var/task/output/purge-merge-automation/index.js:22043:21)
at ParamValidator.validate (/var/task/output/purge-merge-automation/index.js:21989:10)
at Request.VALIDATE_PARAMETERS (/var/task/output/purge-merge-automation/index.js:19767:42)
at Request.callListeners (/var/task/output/purge-merge-automation/index.js:25757:20)
at callNextListener (/var/task/output/purge-merge-automation/index.js:25747:12)
at /var/task/output/purge-merge-automation/index.js:19721:9
at finish (/var/task/output/purge-merge-automation/index.js:14369:7)
at /var/task/output/purge-merge-automation/index.js:14387:9
at EnvironmentCredentials.get (/var/task/output/purge-merge-automation/index.js:14925:7)
at getAsyncCredentials (/var/task/output/purge-merge-automation/index.js:14381:24)
at Config.getCredentials (/var/task/output/purge-merge-automation/index.js:14401:9)
at Request.VALIDATE_CREDENTIALS (/var/task/output/purge-merge-automation/index.js:19716:26)
at Request.callListeners (/var/task/output/purge-merge-automation/index.js:25753:18)
at Request.emit (/var/task/output/purge-merge-automation/index.js:25729:10) {
code: 'MissingRequiredParameter',
time: 2023-07-11T10:39:32.990Z
}
Contributor guide
Research direction
Start with the TypeScript snippet in the issue and the AWS DynamoDB DocumentClient batchGet entry point; compare the arguments shown with the API's expected request structure. Reproduce the reported MissingRequiredParameter error and confirm the intended example behavior before documenting or correcting the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100