当前位置:网站首页>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
边栏推荐
- LeetCode 74、搜索二维矩阵
- JS arrow function user and processing method of converting arrow function into ordinary function
- Implementation of mypromise
- Latest investigation and progress of building intelligence based on sati
- LeetCode 116. Populate the next right node pointer for each node
- JDBC tool class jdbcconutil gets the connection to the database
- Three. Based on ply format point cloud voxel model JS upload interface writing
- After route link navigation, the sub page does not display the navigation style problem
- LeetCode 1346、检查整数及其两倍数是否存在
- SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
猜你喜欢
Click an EL checkbox to select all questions
ArcGIS JS version military landmark drawing (dovetail arrow, pincer arrow, assembly area) fan and other custom graphics
2022dasctf APR x fat epidemic prevention challenge crypto easy_ real
Don't bother tensorflow learning notes (10-12) -- Constructing a simple neural network and its visualization
A useless confession artifact
LeetCode 74、搜索二维矩阵
The ODB model calculates the data and outputs it to excel
Install MySQL 5.0 under Linux 64bit 6 - the root password cannot be modified
Development of Matlab GUI bridge auxiliary Designer (functional introduction)
DNS cloud school | quickly locate DNS resolution exceptions and keep these four DNS status codes in mind
随机推荐
Monte Carlo py solves the area problem! (save pupils Series)
Devaxpress report replay: complete the drawing of conventional two-dimensional report + histogram + pie chart
LeetCode 542、01 矩阵
Leetcode 1346. Check whether integers and their multiples exist
Browser - learning notes
selenium. common. exceptions. WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
Rt-1052 learning notes - GPIO architecture analysis
The construction and use of Fortress machine and springboard machine jumpserver are detailed in pictures and texts
Numpy Index & slice & iteration
The market share of the financial industry exceeds 50%, and zdns has built a solid foundation for the financial technology network
PostgreSQL basic functions
【栈和队列专题】—— 滑动窗口
2022DASCTF Apr X FATE 防疫挑战赛 CRYPTO easy_real
Error reported by Azkaban: Azkaban jobExecutor. utils. process. ProcessFailureException: Process exited with code 127
DOS command of Intranet penetration
Leetcode 232, queue with stack
The flinkcdc reports an error: but this is no longer available on the server
Leetcode 542, 01 matrix
2022dasctf APR x fat epidemic prevention challenge crypto easy_ real
论文写作 19: 会议论文与期刊论文的区别