Skip to Content
工具程式碼產生器

程式碼產生器

選擇常用端點,產生可直接修改的 TypeScript、axios、curl 或 Python httpx 請求。

產生的請求tables.create
export async function callTablesCreate(): Promise<unknown> {
  const res = await fetch("https://api.scfg.io/private/module/custom_tables/chatroom/11111111-1111-4111-8111-111111111111/tables", {
    method: "POST",
    headers: {
      "Authorization": "Bearer <YOUR_TOKEN>",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "name": "訂單",
      "description": "客戶訂單",
      "schema_definition": {
        "columns": [
          {
            "name": "品項",
            "type": "string",
            "required": true,
            "max_length": 120
          },
          {
            "name": "數量",
            "type": "integer",
            "default_value": 1
          }
        ]
      }
    }),
  })

  if (!res.ok) {
    throw new Error(`Request failed: ${res.status} ${res.statusText}`)
  }

  return res.json()
}
Last updated on