diff --git a/messenger.js b/messenger.js index 1dc9ada..5d0ef10 100644 --- a/messenger.js +++ b/messenger.js @@ -80,6 +80,8 @@ module.exports = { return result } }) + }).catch((error)=>{ + return { _state: 'SMS_SEND_FAIL', error } }) }, @@ -108,16 +110,16 @@ module.exports = { TemplateParam: JSON.stringify(msgParam), //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时。 }) .then( - function (res) { - let { Code } = res + function (result) { + let { Code } = result if (Code === 'OK') { return { _state: 'SMS_SENT_SUCCESS' } } else { - return { _state: 'SMS_SEND_FAIL', result: res } + return { _state: 'SMS_SEND_FAIL', result } } }, - function (err) { - return { _state: 'SMS_SEND_ERROR', error: err } + function (error) { + return { _state: 'SMS_SEND_ERROR', error } } ) },