先看报错:

(node:24460) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefinedat getAllUser (file:///G:/MarkDownNote/vue/example_code/apiTest/controler/user_ctrl.js:6:6)   at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:24460) 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(). T
o 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:24460) [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.

代码:

import db from '../db/index.js'//导出getAllUser
export async function getAllUser (req, res) {const [rows] = await db.query('select id,username,nickname from ev_user')res.send({status: 0,message: 'success',data: rows})/*res.status(200).json({status: 0,message: 'success',data: rows})*/
}// console.log(getAllUser())getAllUser()/*.catch(() => {console.log('error already done')
})*/

主要报错是:UnhandledPromiseRejectionWarning,关于这个也不再赘述,毕竟有很多博客写过这个报错的原因,
它报错在send,说明getAllUser()这个方法没有失败的处理函数,需要在调用时,处理:

getAllUser().then(()=>{console.log('then')},()=>{console.log('catch')})
// 或者:
getAllUser().catch(() => {console.log('error already done')
})

UnhandledPromiseRejectionWarning报错send()的处理相关推荐

  1. 记录webpack使用问题,使用报错“UnhandledPromiseRejectionWarning,file-loader图片过大,无法加载图片,打包html文件报错TypeError

    记录webpack使用报错 版本号问题 运行npm run build,报错 "UnhandledPromiseRejectionWarning: TypeError: this.getRe ...

  2. 搭建elsticsearch集群 报错 failed to send join request to master [{data-node-0}(已经测试)

    版权声明:本文为博主原创文章,未经博主允许不得转载.    https://blog.csdn.net/qq_24879495/article/details/77718032 搭建elsticsea ...

  3. TypeError: can‘t send non-None value to a just-started generator-python报错问题

    https://blog.csdn.net/hanhanwanghaha宝藏女孩 欢迎您的关注! 欢迎关注微信公众号:宝藏女孩的成长日记 如有转载,请注明出处(如不注明,盗者必究) TypeError ...

  4. Nginx报错:upstream timed out (110: Connection timed out)和client intended to send too large body【转】...

    nginx日志报错 2018/01/26 16:36:49 [error] 23327#0: *54953 upstream timed out (110: Connection timed out) ...

  5. 【Flink】Flink 写入 kafka 报错 Failed to send data to Kafka: Expiring 4 record(s) for 20001 ms has passed

    文章目录 1.场景1 1.1 概述 1.2 百度 1.3 同样问题 2.场景再现 本文为博主九师兄(QQ:541711153 欢迎来探讨技术)原创文章,未经允许博主不允许转载. 1.场景1 1.1 概 ...

  6. requests模块报错:Use body.encode('utf-8') if you want to send it encoded in UTF-8.

    在做 企业向微信用户个人付款  功能时,调用第三方sdk,在 进行 requests 的post请求时, 代码如下 req = requests.post(url, data=data,cert(ap ...

  7. Ubuntu执行脚本报错-bash: ./send.py: /usr/bin/python: bad interpreter: Permission denied

    在Ubuntu系统终端中,使用命令行如下命令行运行*.py文件: 执行脚本报错 root@ubuntu:/usr/bin/python# chmod a+x send.py root@ubuntu:/ ...

  8. 解决Pycharm绘图报错:Error: failed to send plot to http://127.0.0.1:63342

    pycharm 2021.3.3专业版, python scientific模式 使用plt.show()绘制的图像只能在工具窗口(SciView)中显示,无法使用弹出窗口,取消"在工具窗口 ...

  9. ng serve 报错: 95% emitting LicenseWebpackPlugin(node:21768) UnhandledPromiseRejectionWarning…

    今天升级了Angular-cli版本到:Angular CLI: 6.2.4 后,初始化了个新项目,cnpm install 安装好依赖后 ng serve 报错. 报错信息如下: ** Angula ...

最新文章

  1. 辛湜推荐的数据库领域的一些学习材料
  2. Keil uVision5中配置stm32标准固件库v3.5
  3. 解析Python中的条件语句和循环语句
  4. 查看Linux 下某个程序的内存情况
  5. Linux 调优篇:虚拟化调优(hugepage 大页内存)* 叁
  6. 你根本不懂rebase-使用rebase打造可读的git graph
  7. Apache CarbonData 1.5.0编译及安装
  8. 知名Node.js组件存在代码注入漏洞
  9. maven一键部署tomcat war包
  10. SPSS的中分层聚类法的实际应用详解
  11. ps渐隐在哪里以及ps渐隐知识点总结
  12. EOF 键盘输入end of file
  13. 为什么Google要将LiveData设计成粘性的
  14. Rust基础-Vec用法
  15. directshow使用Sample Grabber采样
  16. 泡一杯清茶,看窗外细细的雨
  17. 阿里云免费ssh证书的免费购买,创建、下载,部署证书详细步骤
  18. C#winform小demo-串口传输实现硬件数据回传(数据处理/输出txt文件保存)
  19. js处理blur事件触发多次
  20. 【写在中秋时刻】硬件冷钱包、软件冷钱包、多签(Multisig)钱包多视角比较分析

热门文章

  1. Tapestry 和 JSF
  2. 一种简单的可控并发粒度的TaskScheduler的实现
  3. 递归——幂次方(洛谷 P1010)
  4. c语言1A,C程序设计语言1a.ppt
  5. MLOG_CHECKPOINT缺失下紧急数据恢复
  6. 资源放送丨《Oracle DataGuard 备份恢复最佳实践 》PPT视频
  7. 嘉年华回顾丨Eygle带你领略数据库技术和生态的发展演进
  8. 20个MySQL高性能架构设计原则(收藏版)
  9. 结合 Apache Kafka 生态系统,谈谈2018年机器学习五大趋势
  10. 新生代农民工的十八般武艺,你都了解吗