登录
注册
开源
企业版
高校版
搜索
帮助中心
使用条款
关于我们
开源
企业版
高校版
私有云
Gitee AI
NEW
我知道了
查看详情
登录
注册
代码拉取完成,页面将自动刷新
开源项目
>
微信开发
>
微信开发包
&&
捐赠
捐赠前请先登录
取消
前往登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
Watch
不关注
关注所有动态
仅关注版本发行动态
关注但不提醒动态
109
Star
650
Fork
198
Javen
/
TNWX
代码
Issues
6
Pull Requests
0
Wiki
统计
流水线
服务
Gitee Pages
质量分析
Jenkins for Gitee
腾讯云托管
腾讯云 Serverless
悬镜安全
阿里云 SAE
Codeblitz
我知道了,不再自动展开
申请加入仓库
更新失败,请稍后重试!
Issues
/
详情
移除标识
内容风险标识
本任务被
标识为内容中包含有代码安全 Bug 、隐私泄露等敏感信息,仓库外成员不可访问
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
待办的
#I6EJC6
俊瑶先森
创建于
2023-02-12 22:31
``` @Post('/msg/callback') @ApiOperation({ summary: '公众号消息/事件回调处理' }) async handleMpCallback(@Req() req, @Res() res) { console.log(req.query) let appId: string = req.query.appId if (appId) { ApiConfigKit.setCurrentAppId(appId) } // 获取签名相关的参数用于消息解密(测试号以及明文模式无此参数) const { signature, timestamp, nonce } = req.query; let buffer: Uint8Array[] = []; req.on('data', (data: any) => { buffer.push(data); }); req.on('end', () => { let msgXml = Buffer.concat(buffer).toString('utf-8'); console.log(msgXml) WeChat.handleMsg( new MsgController(), msgXml, signature, timestamp, nonce, ).then((data) => { console.log('data', data) res.send(data) }).catch(error => console.log("error", error)) }) } ``` ``` <xml><ToUserName><![CDATA[gh_029c12ae1cba]]></ToUserName> <FromUserName><![CDATA[orgKLwWyy9DqBT7ipkkzID50H8PU]]></FromUserName> <CreateTime>1676212138</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[1]]></Content> <MsgId>23997586448432458</MsgId> </xml> (node:14807) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined at new NodeError (internal/errors.js:322:7) at Decipheriv.update (internal/crypto/cipher.js:157:11) at CryptoKit.decryptMsg (/Users/hongjunyao/Desktop/common_backend/node_modules/@tnwx/commons/src/CryptoKit.ts:79:52) at /Users/hongjunyao/Desktop/common_backend/node_modules/@tnwx/wxmp/src/WeChat.ts:110:30 at Generator.next (<anonymous>) at /Users/hongjunyao/Desktop/common_backend/node_modules/@tnwx/wxmp/dist/WeChat.js:8:71 at new Promise (<anonymous>) at __awaiter (/Users/hongjunyao/Desktop/common_backend/node_modules/@tnwx/wxmp/dist/WeChat.js:4:12) at /Users/hongjunyao/Desktop/common_backend/node_modules/@tnwx/wxmp/dist/WeChat.js:76:24 at Parser.<anonymous> (/Users/hongjunyao/Desktop/common_backend/node_modules/xml2js/lib/parser.js:304:18) (Use `node --trace-warnings ...` to show where the warning was created) (node:14807) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:14807) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. ```
``` @Post('/msg/callback') @ApiOperation({ summary: '公众号消息/事件回调处理' }) async handleMpCallback(@Req() req, @Res() res) { console.log(req.query) let appId: string = req.query.appId if (appId) { ApiConfigKit.setCurrentAppId(appId) } // 获取签名相关的参数用于消息解密(测试号以及明文模式无此参数) const { signature, timestamp, nonce } = req.query; let buffer: Uint8Array[] = []; req.on('data', (data: any) => { buffer.push(data); }); req.on('end', () => { let msgXml = Buffer.concat(buffer).toString('utf-8'); console.log(msgXml) WeChat.handleMsg( new MsgController(), msgXml, signature, timestamp, nonce, ).then((data) => { console.log('data', data) res.send(data) }).catch(error => console.log("error", error)) }) } ``` ``` <xml><ToUserName><![CDATA[gh_029c12ae1cba]]></ToUserName> <FromUserName><![CDATA[orgKLwWyy9DqBT7ipkkzID50H8PU]]></FromUserName> <CreateTime>1676212138</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[1]]></Content> <MsgId>23997586448432458</MsgId> </xml> (node:14807) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined at new NodeError (internal/errors.js:322:7) at Decipheriv.update (internal/crypto/cipher.js:157:11) at CryptoKit.decryptMsg (/Users/hongjunyao/Desktop/common_backend/node_modules/@tnwx/commons/src/CryptoKit.ts:79:52) at /Users/hongjunyao/Desktop/common_backend/node_modules/@tnwx/wxmp/src/WeChat.ts:110:30 at Generator.next (<anonymous>) at /Users/hongjunyao/Desktop/common_backend/node_modules/@tnwx/wxmp/dist/WeChat.js:8:71 at new Promise (<anonymous>) at __awaiter (/Users/hongjunyao/Desktop/common_backend/node_modules/@tnwx/wxmp/dist/WeChat.js:4:12) at /Users/hongjunyao/Desktop/common_backend/node_modules/@tnwx/wxmp/dist/WeChat.js:76:24 at Parser.<anonymous> (/Users/hongjunyao/Desktop/common_backend/node_modules/xml2js/lib/parser.js:304:18) (Use `node --trace-warnings ...` to show where the warning was created) (node:14807) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:14807) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. ```
评论 (
0
)
俊瑶先森
创建了
任务
登录
后才可以发表评论
状态
待办的
待办的
进行中
已完成
已关闭
负责人
未设置
标签
未设置
标签管理
里程碑
未关联
未关联
Pull Requests
未关联
未关联
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
未关联
未关联
dev
master
egg-template
gh-pages
开始日期   -   截止日期
-
置顶选项
不置顶
置顶等级:高
置顶等级:中
置顶等级:低
优先级
不指定
严重
主要
次要
不重要
参与者(1)
TypeScript
1
https://gitee.com/javen205/TNWX.git
git@gitee.com:javen205/TNWX.git
javen205
TNWX
TNWX
点此查找更多帮助
搜索帮助
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册