"there are no users authenticated" - MongoDB and Mongoose - Create and Save a Record of a Model

"there are no users authenticated" - MongoDB and Mongoose - Create and Save a Record of a Model
0
#1

Hello!

I’m completing the “MongoDB and Mongoose - Create and Save a Record of a Model” challenge and am getting the message: “there are no users authenticated.”

Here is the code used to create the model and save the record of the model:

var Schema = mongoose.Schema;

var personSchema = new Schema({
  name:  {
    type: String,
    required: true
  },
  age: Number,
  favoriteFoods:   [String]
});

var Person = mongoose.model('Person', personSchema);

var createAndSavePerson = function(done) {
 var person = new Person(
   {name: 'Ryan', 
    age: 28, 
    favouriteFoods: ['vegan snacks']})
  person.save(function(err, data) {
    return(err 
           ? 
           done(err) 
           : 
           done(null, data)
          )});
             }

Mongoose has been successfully connected to the MongoDB.

I imagine this is an issue w/ adding a user to MongoDB?

Any help is appreciated!

#2

I think you must fix the minor typos (line break, semicolon) to pass the tests.

#3

Thanks for the suggestion.

I tried fixing little bugs, to no avail. I even added this code, which someone in another post said worked for them:

var createAndSavePerson= function(done) {
  var person = new Person({name:'Ryan', age: 28, favoriteFoods: ['vegan snacks']});
  person.save((err, data) => err ? done(err) : done(null, data));
};

I’m still getting the message: “there are no users authenticated.”

#4

:thinking: Try get the data with console.log()

person.save((err, data) => {
  if (err)  return done(err);
  console.log(data);
  done(null, data);
});

I would see the DB in the mlab site. Do this store the record?

#5

I don’t see any changes in mlab

#6

The first bit of code has a certain property and the block of code following it has a very, very similar but technically different property:

var personSchema = new Schema({
  name:  {
    type: String,
    required: true
  },
  age: Number,
  favoriteFoods:   [String]
});
var createAndSavePerson = function(done) {
 var person = new Person(
   {name: 'Ryan', 
    age: 28, 
    favouriteFoods: ['vegan snacks']})

I’m not saying this will give you a problem fix, but you should at least be aware of it.

#7

Good eye!

Thanks for the typo catch. The “favourite => favorite” correction doesn’t fix it, unfortunately.

#8

I still can’t get this to work. Anybody have ideas?

#9

Resolved it. It was a typo in the .env file. Thanks for helping out, willjw3 and yoelvis!

#10

I am getting the error timeout has occured

glitch.com

Glitch

Combining automated deployment, instant hosting & collaborative editing, Glitch gets you straight to coding so you can build full-stack web apps, fast

any help will be appreciated