Hi Guys New to sst. I created a second dynamodb ta...
# help
n
Hi Guys New to sst. I created a second dynamodb table called "Events" and am trying to write data to it from a newly created frontend page, but for some reason it keeps trying to write to the other table "Notes". I followed the guide from Serverless-Stack. How do I specify which table should be written to? I call this from the frontend page:
Copy code
function createEvent(content) {
    return <http://API.post|API.post>("notes", "/events", {
        body: content
    });
    
  }
I tried to add this to routes in ApiStack.js:
Copy code
"POST /events": "src/createEvent.main",
With this createEvent:
Copy code
import * as uuid from "uuid";
import handler from "./util/handler";
import dynamoDb from "./util/dynamodb";

export const main = handler(async (event) => {
  const data = JSON.parse(event.body);
  const params = {
    TableName: process.env.TABLE_NAME,
    Item: {
      // The attributes of the item to be created
      eventId: uuid.v1(), // A unique uuid
      name: data.content, // Parsed from request body
      max_players: data.max_players,
      createdAt: Date.now(), // Current Unix timestamp
    },
  };

  await dynamoDb.put(params);

  return params.Item;
});
Added this to StorageStack.js:
Copy code
this.table2 = new sst.Table(this, "Events", {
  fields: {

    eventId: sst.TableFieldType.STRING,

  },

  primaryIndex: { partitionKey: "eventId" },

});
If you need anything else from me, let me know 🙂