0

How to use guest() access to data in aws amplify gen2 ? While i have added the product as the owner, the product is not fetched while listing the products when i am not logged in. This is not working for me.

Product: a
    .model({
      name: a.string().required(),
      description: a.string(),
      price: a.float().required(),
      image: a.string().required(),
      categoryId: a.id(),
      category: a.belongsTo('Category', 'categoryId'),
      sellerId: a.id(),
      seller: a.belongsTo('Profile', 'sellerId'),
      status: a.enum(["active", "disabled"])
    })
    .authorization((allow) => [
      allow.guest().to(["read"]),
      allow.authenticated().to(['read']),
      allow.owner().to(["create", "read", "update", "delete"])
    ]),

xport type Schema = ClientSchema<typeof schema>;

export const data = defineData({
  schema,
  authorizationModes: {
    defaultAuthorizationMode: 'userPool',
    apiKeyAuthorizationMode: {
      expiresInDays: 30,
    },
  },
});

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.