Quickstart
Requirement
- Node.js (Version 8.9.3 or later)
- npm (Version 5.5.1 or later)
- WeChat Developer Tool (The latest)
Base library version of the Mini Program: 2.2.1 or later
How to use
Step 1
Open WeChat Developer Tool and create a new project. (Ref. 微信开发者工具)
Step 2
Use command tool to run following commands.
cd your-project-directory
npm init
npm install --save @kintone/kintone-wechat-miniprogram-sdk
Step 3
At "WeChat Developer Tool"
Check the setting "增强编译". (Ref. 代码编译 - 增强编译)
Click "工具" > "构建npm" (Ref. npm 支持)
Code example
Get record sample
Source codeconst kintone = require('@kintone/kintone-wechat-miniprogram-sdk'); let kintoneAuthWithAPIToken = (new kintone.Auth()).setApiToken({apiToken: 'MY_TOKEN'}); let kintoneConnection = new kintone.Connection({domain: 'your.FQDN.tld', auth: kintoneAuthWithAPIToken}); let kintoneRecord = new kintone.Record({connection: kintoneConnection}); let appID = 'your_app_id'; let recordID = 'record_id_that_will_be_retrived'; kintoneRecord.getRecord({app: appID, id: recordID}) .then((rsp) => { console.log(rsp); }) .catch((err) => { // The promise function always reject with KintoneAPIException console.log(err.get()); });Response success
{ "record":{ // record data should be here } }Response error
{ id: '{ID}', code: '{CODE}', message: '{Message string}', errors: '{JSON String}' }
Get record sample with Async
Source codeconst kintone = require('@kintone/kintone-wechat-miniprogram-sdk'); let kintoneAuthWithAPIToken = (new kintone.Auth()).setApiToken({apiToken: 'MY_TOKEN'}); let kintoneConnection = new kintone.Connection({domain: 'your.FQDN.tld', auth: kintoneAuthWithAPIToken}); let kintoneRecord = new kintone.Record({connection: kintoneConnection}); let appID = 'your_app_id'; let recordID = 'record_id_that_will_be_retrived'; let getRecord = async () => { try { let recordResult = await kintoneRecord.getRecord({app: appID, id: recordID}); console.log(recordResult); } catch (error) { // The promise function always reject with KintoneAPIException console.log(error.get()); } } getRecord();Response success
{ "record":{ // record data should be here } }Response error
{ id: '{ID}', code: '{CODE}', message: '{Message string}', errors: '{JSON String}' }