0
Get item list from a NocoDb table
One script reply has been approved by the moderators Verified

Fetch the nocodb api and return the items of the selected table

Created by yassinsiouda74165 758 days ago Viewed 22896 times
0
Submitted by yassinsiouda74165 Deno
Verified 758 days ago
1
type Nocodb = {
2
  apiUrl: string;
3
  xc_token: string;
4
  table: string;
5
  workspace: string;
6
};
7
export async function main(nocodb: Nocodb, limit: number) {
8
  // request from nocodb
9
  const res = await fetch(
10
    `${nocodb.apiUrl}/api/v1/db/data/v1/${nocodb.workspace}/${nocodb.table}?limit=${limit}`,
11
    {
12
      headers: {
13
        "Content-Type": "application/json",
14
        "xc-token": nocodb.xc_token,
15
      },
16
    },
17
  );
18
  const data = await res.json();
19
  return data;
20
}
21