I have a React App hosted locally on my Mac. I am using Material-Table to organize my data and a serverless backend. I have my data stored in a DynamoDB table (4000 rows) and I am using Amplify, API Gateway and Lambda for endpoints and requests.
I am experiencing a strange issue, only about 2,023 rows are showing up in the Material-Table however there are 4000 rows in DynamoDB. When I added 1000 extra rows to Dynamo the Material-Table only shows 1,950 rows. I am very confused about this.
I thought it could be that the provisioned setting in Dynamo was limiting how much I was able to see in the Material-Table. But I changed the plan to "On-Demand" and still having the same problem.
I attached one image of the material-table count, and the dynamodb count for comparison.
Here is the Get function I have in my react app:
try{
const res = await axios.get(`${config.api.invokeUrl}/products`);
const products = res.data;
this.setState({products: products});
}catch (err){
console.log(`an error has occured while getting2: ${err}`);
}
}
componentDidMount = () => {
this.getProdFromDB();
}
Any help is greatly appreciated. Also there are No Errors in the Console.
Here is my Lambda Function for getting the items.
'use strict';
const AWS = require('aws-sdk');
exports.handler = async (event, context) => {
const documentClient = new AWS.DynamoDB.DocumentClient();
let responseBody = '';
let statusCode = 0;
const params = {
TableName: "Products"
};
//document scan , you can set filter expressions
try {
const data = await documentClient.scan(params).promise();
responseBody = JSON.stringify(data.Items);
statusCode = 200;
} catch(err) {
responseBody = `Unable to get product: ${err}`;
statusCode = 403;
}
const response = {
statusCode: statusCode,
headers: {
"Content-Type": "application/json",
"access-control-allow-origin": "*"
},
body: responseBody
};
return response;
};