javascript - UnhandledPromiseRejectionWarning:ReferenceError:未定义字符串
问题描述
我的 Express JS API 端点中有一个简单的条件,我使用 typeof 检查输入的值是否为字符串。
if (!name || typeof name != 'string') {
res.status(400).json({
success: false,
message: 'Please enter the meal name correctly! (Hint: name must be a string)'
});
}
问题是它不断抛出这个错误:UnhandledPromiseRejectionWarning: ReferenceError: string is not defined
. 我的代码有什么问题?
提前致谢。
解决方案
推荐阅读
- jquery - 使用图像 CSS 缩放悬停
- gnuplot - 带有统计信息的 gnuplot 打印列标题
- typescript - VueJS (Typescript) - SVG 不渲染
- c++ - 检查cpp文件中是否使用了变量
- javascript - 如何在一天中的不同时间设置机器人的状态?
- java - 无法通过maven从java向Neo4j数据库插入多条记录
- javascript - CSS 样式问题 - 未在 Firefox 中显示
- elasticsearch - elasticsearch混合映射动态对象
- python - Errno 32 带有 multiprocessing.Queue 的管道损坏错误
- spring - 如何使用 Swagger 生成 Spring Boot REST 客户端