简介 & 安装 & 快速上手
mixin 的 nodejs 版 sdk
新版本特性#
- 更友好的类型和代码提示
- 更规范的函数命名
- 更全面的测试覆盖
安装#
npm install mixin-node-sdk如果你使用 yarn
yarn add mixin-node-sdk使用#
- 仅使用 Mixin 的 Api
const { Client } = require('mixin-node-sdk');const client = new Client({ client_id: '', session_id: '', pin_token: '', private_key: '', pin: '', client_secret: '',});// 使用 Promiseclient.userMe().then(console.log);
// 使用 async awaitasync function getMe() { const me = await client.userMe(); console.log(me);}- 使用 Mixin 的消息功能()
const { BlazeClient } = require('mixin-node-sdk');const client = new BlazeClient( { client_id: '', session_id: '', pin_token: '', private_key: '', pin: '', client_secret: '', }, { parse: true, syncAck: true });
client.loopBlaze({ onMessage(msg) { console.log(msg); },});提示
BlazeClient 直接继承了 Client,所以所有 Client 的方法 BlazeClient 都可以直接调用。
提示
如果你使用的是 mixin-node-sdk@2.xx.xx 的版本,请看 https://github.com/liuzemei/mixin-node-sdk