1.2.2 • Published 6 years ago

egg-wechat-api v1.2.2

Weekly downloads
24
License
MIT
Repository
github
Last release
6 years ago

egg-wechat-api

NPM version build status Test coverage David deps Known Vulnerabilities npm download

egg plugin for wechat-api

Install

$ npm i egg-wechat-api --save

Prerequisite

Node.js >= 7.x

Usage

Dependencies

Configuration

// {app_root}/config/plugin.js
exports.wechatApi = {
  enable: true,
  package: 'egg-wechat-api',
};

if redis is single client

// {app_root}/config/config.default.js
exports.wechatApi = {  
  appId: '',
  appSecret: '',
};

if redis is multi clients

// {app_root}/config/config.default.js
exports.wechatApi = {
  appId: '',
  appSecret: '',
  redisInstance: '', // select instance of redis
};

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.

License

MIT

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago