I am using aws-amplify in my react-native application for user authentication. it works fine.
modules used for aws amplify
aws-amplify: "^3.0.23", aws-amplify-react-native: "^4.2.4"
Now I would like to connect the app or retrieve the data from a DynamoDB table and use that data in my react native application.
How can I Access data from Dynamodb tables in react native using aws-amplify is there any get methods or rest APIs to retrieve data from dynamodb.
How can I establish a connection with dB to my react-native application.
Thanks in advance.
I used
aws-sdk/dist/aws-sdk-react-native
var AWS = require('aws-sdk/dist/aws-sdk-react-native');
AWS.config.update({
region: 'your region',
dynamoDbCrc32: false
});
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'your identityPool Id'
});
const gp = AWS.config.credentials.getPromise();
gp.then(() => {
const documentClient = new AWS.DynamoDB.DocumentClient();
const params = {
TableName: "table name",
Key: "your key",
};
documentClient.get(params, function(err, data) {
if (err){
console.log(err)
} else {
console.log(data)
}
}