# Add an API to List All the Notes

**URL:** <https://discourse.sst.dev/t/add-an-api-to-list-all-the-notes/2455>\
**Category:** Chapter Comments\
**Created:** [August 26, 2021, 1:12am UTC](https://discourse.sst.dev/t/add-an-api-to-list-all-the-notes/2455 "2021-08-26T01:12:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [August 26, 2021, 1:12am UTC](https://discourse.sst.dev/t/add-an-api-to-list-all-the-notes/2455/1 "2021-08-26T01:12:24Z")

</div>

Link to chapter — [https://serverless-stack.com/chapters/add-an-api-to-list-all-the-notes.html](https://serverless-stack.com/chapters/add-an-api-to-list-all-the-notes.html)

---

<div class="post-metadata">

**Author:** ![willjstevens](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/willjstevens/32/487_2.png) [@willjstevens](https://discourse.sst.dev/u/willjstevens)\
**Post date:** [June 25, 2022, 12:06am UTC](https://discourse.sst.dev/t/add-an-api-to-list-all-the-notes/2455/2 "2022-06-25T00:06:57Z")

</div>

When clicking Send the console is not displaying anything, like shown in the guide. The console displays nothing. However it is shown in the terminal in VS Code.

I believe it is because the handler is invoking an async anonymous function which does not return to the console browser. Yet, this is inconsistent with what the guide shows.

---

<div class="post-metadata">

**Author:** ![willjstevens](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/willjstevens/32/487_2.png) [@willjstevens](https://discourse.sst.dev/u/willjstevens)\
**Post date:** [June 25, 2022, 12:30am UTC](https://discourse.sst.dev/t/add-an-api-to-list-all-the-notes/2455/3 "2022-06-25T00:30:34Z")

</div>

I found the reason for this is I was running the debugger during that execution. Run normal without the debugger and output goes to the console.

---

<div class="post-metadata">

**Author:** ![pavelloz](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/pavelloz/32/1532_2.png) [@pavelloz](https://discourse.sst.dev/u/pavelloz)\
**Post date:** [March 22, 2024, 2:17pm UTC](https://discourse.sst.dev/t/add-an-api-to-list-all-the-notes/2455/4 "2024-03-22T14:17:04Z")

</div>

Hey Folks,

Im trying to follow the tutorial, but i got stuck on this part.

This is the error i get when calling `GET /notes`:

```auto
    "error": "One or more parameter values are not valid. The AttributeValue for a key attribute cannot contain an empty string value. Key: noteId"

```

This is the code in list.ts (its the same as in the tutorial in my opinion, but maybe i just made a typo somewhere, so just in case, im pasting):

```js
import { Table } from "sst/node/table";
import handler from "@notes/core/handler";
import dynamoDb from "@notes/core/dynamodb";

export const main = handler(async (event) => {
    const params = {
        TableName: Table.Notes.tableName,
        KeyConditionExpression: "userId = :userId",
        ExpressionAttributeValues: {
            ":userId": "123"
        }
    }

    const result = await dynamoDb.query(params)

    return JSON.stringify(result.Items)
})

```

* * *

Im not sure why index endpoint would need noteId to display notes for the userId, but i think it might have something to do with how the table is being created:

```js
 const table = new Table(stack, "Notes", {
    fields: {
      userId: "string",
      noteId: "string",
    },
    primaryIndex: { partitionKey: "userId", sortKey: "noteId" },
  });

```

My theory is probably wrong because i didnt fully understand the sortkey/primarykey/index explanation yet.

Did anyone had similar error? I’ve seen someone having 500 returned, but thats definietly not the same. It looks like a legit error from DynamoDB.

Cheers, Pawel
