Skip to content

记录

查询记录。

const TOKEN = 'teable_123456';
const TABLE_ID = 'tbl123456';

const url = 'https://app.teable.cn/api/table/' + TABLE_ID + '/record';
const options = {method: 'GET', headers: {Authorization: 'Bearer ' + TOKEN}};

try {
  const response = await fetch(url, options);
  const data = await response.text();
  console.log(data);
} catch (error) {
  console.error(error);
}

查询记录,使用 SQL 。

const TOKEN = 'teable_123456';
const BASE_ID = 'bse123456';
const DB_TABLE_NAME = `"bse123456"."Biao_Ge"`;

const url = 'https://app.teable.cn/api/base/' + BASE_ID + '/sql-query';
const sql = {sql: `SELECT * FROM ${DB_TABLE_NAME} LIMIT 10`}
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer ' + TOKEN,
    'content-type': 'application/json'
  },
  body: JSON.stringify(sql)
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}

联系 math@baima.site