close

[Solved] cursor.toArray is not a function collection.find() accepts at most two arguments unhandled promise rejections are deprecated while using .find()

Hello Guys, How are you all? Hope You all Are Fine. Today I am using nodejs with MongoDB and mongoose 6.0 and I am facing the following error cursor.toArray is not a function collection.find() accepts at most two arguments unhandled promise rejections are deprecated while using .find() nodejs. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How cursor.toArray is not a function collection.find() accepts at most two arguments unhandled promise rejections are deprecated while using .find() Occurs ?

Today I am using nodejs with MongoDB and mongoose 6.0 and I am facing the following error.

(Use `node --trace-warnings ...` to show where the warning was created)
(node:13720) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--u
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:13720) [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.

How To Solve cursor.toArray is not a function collection.find() accepts at most two arguments unhandled promise rejections are deprecated while using .find() ?

  1. How To Solve cursor.toArray is not a function collection.find() accepts at most two arguments unhandled promise rejections are deprecated while using .find() ?

    To Solve cursor.toArray is not a function collection.find() accepts at most two arguments unhandled promise rejections are deprecated while using .find() This issue is facing mongoose version 6.0 So you just have to downgrade the mongoose version. Just run npm uninstall mongoose to uninstall the current mongoose version then run npm i mongoose@5.13.8  this will install the version that will fix your problem

  2. cursor.toArray is not a function collection.find() accepts at most two arguments unhandled promise rejections are deprecated while using .find()

    To Solve cursor.toArray is not a function collection.find() accepts at most two arguments unhandled promise rejections are deprecated while using .find() This issue is facing mongoose version 6.0 So you just have to downgrade the mongoose version. Just run npm uninstall mongoose to uninstall the current mongoose version then run npm i mongoose@5.13.8  this will install the version that will fix your problem

Solution 1: Downgrade mongoose version.

This issue is facing mongoose version 6.0 So you just have to downgrade the mongoose version.

Just run npm uninstall mongoose to uninstall the current mongoose version then run npm i mongoose@5.13.8  this will install the version that will fix your problem

Solution 2: Use mongoose version 5.13.8

npm uninstall mongoose
npm i mongoose@5.13.8

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

1 thought on “[Solved] cursor.toArray is not a function collection.find() accepts at most two arguments unhandled promise rejections are deprecated while using .find()”

Leave a Comment