egg-wechat-api
egg plugin for wechat-api
Install
$ npm i egg-wechat-api --save
Prerequisite
Node.js >= 7.x
Usage
Dependencies
- egg
- other
Configuration
// {app_root}/config/plugin.jsexportswechatApi = enable: true package: 'egg-wechat-api';
// {app_root}/config/config.default.jsexportswechatApi = appId: '' appSecret: '';
Redis is required !
see config/config.default.js for more detail.
Example
'use strict';
module.exports = app => {
app.get('/', function* () {
const { wechatApi } = app;
try {
const ticket = yield wechatApi.getTicket();
this.status = 200;
this.body = ticket;
} catch (error) {
this.status = 500;
this.body = error;
}
});
};
Questions & Suggestions
Please open an issue here.