Problems (solved) when adding a record to the database

Tell us what’s happening:
I was having problems running the task ‘Create and Save a Record of a Model’, both locally and in repl. I have finally found the issue after a couple of discouraging days. I thought to post it in case other people have the same problem.

The tests from the previous two problems were passed OK, but when getting to this one I was getting the error GE:

GET
Missing ‘done()’ argument

The solution to the problem was that I had to Enable the Data API on the mongodb atlas website (under Data Services). There you need to select the cluster you are using under ‘Select Data Sources’.

After doing this, another problem got resolved that was giving me an error:
When connecting to the database I was connecting as:

mongoose.connect(process.env.MONGO_URI);

instead of
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });

because the second way was not working. I was, however, getting warnings:

node:3178) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.

After enabling the data API, I can connect the second way without warnings.

Challenge: Create and Save a Record of a Model

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.