I used @model annotation to create a table and a function that adds an entry in that table as a PostAuthentication Trigger to User pool. It works fine when I push it to AWS. But facing some issues in testing it locally.
MockData is there in amplify/mock-data/dynamodb/fake_us-fake-1.db
In the function/function_name/index.js
import AWS from 'aws-sdk';
import { Logger } from '@dev.tools.thinkclear/common-util';
const options = {
region: 'us-fake-1',
endpoint: "<local_url>:62224/",
accessKeyId: "fake",
secretAccessKey: "fake"
};
AWS.config.update( {
region: 'us-fake-1',
endpoint: "<local_url>:62224/",
accessKeyId: "fake",
secretAccessKey: "fake"
});
const dynamoDBClientVar = new AWS.DynamoDB.DocumentClient(options);
// Some Data params
const data = await dynamoDBClient.put(params).promise();
local_url is the same url where amplify mock api is running . Changed the port to 62224 for dynamodb.
amplify mock function function_name
It's throwing Error: NetworkingError: connect ECONNREFUSED error.
Checked this answer for reference: https://stackoverflow.com/a/58925502/4578915