当前位置:网站首页>UnhandledPromiseRejectionwarning:CastError: Cast to ObjectId failed for value
UnhandledPromiseRejectionwarning:CastError: Cast to ObjectId failed for value
2022-04-23 20:30:00 【Different 213】
UnhandledPromiseRejectionwarning:CastError: { One of the solutions }
- Cause of error : I want to query the corresponding in the database id, Delete data . But the result is an error .
The error message is :UnhandledPromiseRejectionwarning:CastError: Cast to ObjectId failed for value " 5ffbb96755245c37047691fa" at path “_id” for model "User
-
My mistake is
req.query.id
The output is the same as what I entered manually id Have the same value , But usefindOne()
The method is to query the corresponding data in the database . Then take a closer look at the terminal display , The discovery may be due to spaces . -
because
req.query.id
There is an error caused by blank space in the print result of .
As shown below, the terminal displays spaces :
The following code is used to test and draw a conclusion :
if (req.query.id.trim() === '5ffbb8e355245c37047691f4') {
console.log(' Results the same ')
} else {
console.log(req.query.id)
}
trim()
Method , Remove the spaces on both sides of the string . The output result is :” Results the same “.
版权声明
本文为[Different 213]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210550451013.html
边栏推荐
- 黑客的入侵方式你知道几种?
- Some basic configurations in interlij idea
- star
- Thirty What are VM and VC?
- Rt-1052 learning notes - GPIO architecture analysis
- LeetCode 232、用栈实现队列
- Solution to PowerDesigner's failure to connect to MySQL in x64 system
- Recommend an open source free drawing software draw IO exportable vector graph
- Confusion about thread blocking after calling the read () method of wrapper flow
- How do BIM swindlers cheat? (turn)
猜你喜欢
LeetCode 994、腐烂的橘子
Browser - learning notes
Wave field Dao new species end up, how does usdd break the situation and stabilize the currency market?
Shanghai a répondu que « le site officiel de la farine est illégal »: l'exploitation et l'entretien négligents ont été « noirs » et la police a déposé une plainte
Customize timeline component styles
Matlab analytic hierarchy process to quickly calculate the weight
A login and exit component based on token
[graph theory brush question-4] force deduction 778 Swimming in a rising pool
What is the difference between a host and a server?
Devaxpress report replay: complete the drawing of conventional two-dimensional report + histogram + pie chart
随机推荐
The problem of 1 pixel border on the mobile terminal
LeetCode 116. 填充每个节点的下一个右侧节点指针
XXXI` Prototype ` displays prototype properties and`__ proto__` Implicit prototype properties
Error reported by Azkaban: Azkaban jobExecutor. utils. process. ProcessFailureException: Process exited with code 64
Browser - learning notes
Commande dos pour la pénétration de l'Intranet
Es index (document name) fuzzy query method (database name fuzzy query method)
三十.什么是vm和vc?
How many hacking methods do you know?
Numpy sort search count set
Leetcode 542, 01 matrix
Commit and ROLLBACK in DCL of 16mysql
Tensorflow 2 basic operation dictionary
LeetCode 20、有效的括号
Plato Farm元宇宙IEO上线四大,链上交易颇高
上海回應“面粉官網是非法網站”:疏於運維被“黑”,警方已立案
DNS cloud school | quickly locate DNS resolution exceptions and keep these four DNS status codes in mind
Leetcode 20. Valid parentheses
Linux64Bit下安装MySQL5.6-不能修改root密码
Leetcode 709, convert to lowercase