我想获取有关Mailgun标签的统计信息,并且关注以下文档:https://bojand.github.io/mailgun-js/#/api/tags
这很好:
const info = await mailgun.tags('my-tag').info()
(它返回{ tag, description, 'first-seen', 'last-seen' }
)
这也有效:
const info = await mailgun.tags('my-tag').stats().aggregates().countries().list()
但是,这:
const info = await mailgun.tags('my-tag').stats().info()
给我:
Error: Missing parameters.
at constructor.impl (my-app/node_modules/mailgun-js/lib/build.js:55:17)
at callback (my-app/node_modules/promisify-call/index.js:32:8)
at my-app/node_modules/with-callback/index.js:39:7
at new Promise (<anonymous>)
at withCallback (my-app/node_modules/with-callback/index.js:5:10)
at promisifyCall (my-app/node_modules/promisify-call/index.js:28:10)
at constructor.promisifed [as info] (my-app/node_modules/mailgun-js/lib/build.js:105:14)
at routeGetEmailStats (my-app/server/routes/email.js:192:59)
at process._tickCallback (internal/process/next_tick.js:68:7)
有什么提示吗?
答案 0 :(得分:0)
事实证明,您需要传递event
作为参数:
const info = await mailgun.tags('my-tag').stats().info({ event: ['delivered', 'opened', 'clicked', 'failed'] })
首先,我将其与mailgun.get
一起使用:
const info = await mailgun.get(`/MY-MAILGUN-DOMAIN/tags/my-tag/stats`, { event: ['delivered', 'opened', 'clicked', 'failed'] })
此外,mailgun.get
提供了更好的错误消息,对我有帮助。