Search code examples
mongodbassertiondenouncaught-exception

error: Uncaught (in promise) AssertionError


I am a new Deno learner, I tried a tutorial code that uses MongoDB but I got the following error:

error: Uncaught (in promise) AssertionError
    throw new AssertionError(msg);
          ^
    at assert (https://deno.land/[email protected]/testing/asserts.ts:224:11)
    at MongoClient.database (https://deno.land/x/[email protected]/src/client.ts:67:5)
    at file:///C:/Users/m/Desktop/Uproject/GuidApp/deno-survey/mongo.ts:6:19

As the project has many files, Let me know if is it needed to add some parts of project codes here? But the whole project code can be find here: https://github.com/thecodeholic/deno-survey


Solution

  • I found that in the mongo.ts file of the project, there is a line like this:

    client.connect(Deno.env.get("MONGODB_URI") || "");
    

    That I must add the await keyword in front of it and change it like below:

    await client.connect(Deno.env.get("MONGODB_URI") || "");
    

    Problem resolved by this.