Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

与egg配合如何调用service #34

Closed
jiangchenguang opened this issue Nov 16, 2017 · 2 comments
Closed

与egg配合如何调用service #34

jiangchenguang opened this issue Nov 16, 2017 · 2 comments

Comments

@jiangchenguang
Copy link

作者你好,最近遇到一个问题:和egg一起使用在处理不同的消息时调用不同的service?

module.exports = app => {
  class HomeController extends app.Controller {}

  // 因为 Egg 需要用类的形式来组织,而 wechat 是通过 middleware 方法来生成中间件
  HomeController.prototype.wechat = wechat({
    token: 'token',
    appid: 'appid',
    encodingAESKey: ''
  }).middleware(async (message, ctx) => {
    // 此处能否调用不同的service?
  });

  return HomeController;
};
@JacksonTian
Copy link
Member

app.service.name.method();

@whileLooper
Copy link

@JacksonTian @jiangchenguang 你能在egg.js上使用co-wechat吗?为什么我按照example的做法做无法使用,微信公众号返回 服务出现故障,请稍后再试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants