I am using Amplify CLI for datastore. It is working fine. But it is not syncing data with dynamodb. Means Post gets save in datastore local storage but does not go in dynamodb POST table. My code is below
const {syncExpression} = require("aws-amplify")
const {Amplify} = require("aws-amplify")
const Post = require("./models")
const awsconfig = require("./aws-exports")
Amplify.configure(awsconfig.awsmobile)
exports.handler = async (event) => {
try {
console.log("inside")
let response=await DataStore.save(
new Post.Post({
title: "My second Post",
status:"DRAFT",
rating: 7
})
);
console.log("Post saved successfully!");
return response;
} catch (error) {
console.log("Error saving post", error);
}
};
It gives the following output:
[WARN] 30:08.206 DataStore - Realtime disabled when in a server-side environment
[WARN] 30:11.411 DataStore - User is unauthorized to query syncPosts with auth mode AWS_IAM. No data could be returned.
Post saved successfully!
Result:
{
"title": "My second Post",
"status": "DRAFT",
"rating": 7,
"id": "0a91a191-a6ee-46ff-9dc6-8cac49498cd9"
}
It says Post is saved but it doesn't show up in dynamodb. Is there any problem with warning?