快速开始
安装
bash
pnpm add @wxstack/oabash
npm add @wxstack/oabash
yarn add @wxstack/oabash
bun add @wxstack/oa注意
wxstack 是仅 ESM 的软件包。不要使用 require() 导入它,并确保最新的 package.json 包含 "type": "module"
我们推荐使用支持 ESM 的 Node.js 版本(16+), 并且使用pnpm作为包管理器以获得最佳体验。
创建客户端
ts
import { createClient } from '@wxstack/oa';
const client = createClient({
appId: 'wx_your_appid',
appSecret: 'your_secret'
});测试调用
ts
await client.ping(); // 示例createClient(options)
可用的 options:
appIdstring(必填):- 必填appSecretstring(必填):- 必填domain('auto'|'disaster'|'shanghai'|'sh'|'shenzhen'|'sz'|'hongkong'|'hk')(可选),默认:'auto'timeoutMsnumber(可选),默认:15000:retry{retries?:number, delayMs?:number}(可选)tokenMode('normal'|'stable')(可选),默认:'normal'tokenPlacement('query'|'header')(可选),默认:'query'tokenKeystring(可选),默认:'access_token'storeimport('./auth/tokenStore.js').InMemoryTokenStore(可选)proxystring(可选)