0
Node/Express/Mongo(mongoose)APIへの呼び出しがある問題があります。ある時点で、渡したパラメータがnullの場合はキャストエラー。ノードを更新した後にヌル値を渡すとエラーが発生する
ブレークポイントは、この呼び出しです:
User.findOne({ _id: ownerId }).then((data) => {
OWNERIDが 'NULL' であるならば、私は次のエラーを取得する:
(node:4186) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CastError: Cast to ObjectId failed for value "" at path "_id" for model "User"
(node:4186) [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
私は最近、最新のノード6.9.5から更新しましたノードのバージョン。
これをどのように処理するかわかりません。
助けが必要ですか? ownerId
が空の文字列であるため、