Challenges for MongoDb section

I’ve tried to pass MongoDb challenges many many times, even I took courses beyound FCC …
and I can say that my solutions doing it’s objectives correctly on my database …
but when it comes to the tests it never passed…
I’m sure there is something i missed corresponding to the nature of these tests,
can you give me some tips to pass these tests

my code is here: https://repl.it/@AhmadAli5/boilerplate-mongomongoose-1
this contains the first 7 challenges solutions, only first 2 solutions have passed

You will need to tell us exactly which challenge you are working on and provide a link to your project code for use to help you further.

1 Like

Please see link to my project: https://steady-aragon.glitch.me

im having the same issues with :

  1. https://www.freecodecamp.org/learn/information-security-and-quality-assurance/advanced-node-and-express/logging-a-user-out

  2. https://www.freecodecamp.org/learn/information-security-and-quality-assurance/advanced-node-and-express/create-new-middleware

1 Like

the code for some challanges is here, only first 2 have passed.

i couldn’t reatch your code on glitch please send me the other link, not the one for live app
this is mycode, https://repl.it/@AhmadAli5/boilerplate-mongomongoose-1

@RandellDawson I think you should look at line 102 in his code. He is defining done callback at line 111. Is that a mistake?

1 Like

because i got an error that done is not defined, so i defined it.

  1. Remove the function done definition on line 111.
  2. Uncomment the code 102 to 109
    3)Delete the code on 106 instead use below. which you have called on 116. Please change it to (ahmad)
 ahmad.save(function(err, data) {
    if (err) return console.error(err);
    done(null, data);
  });

This worked for me.

var createAndSavePerson = function(done) {
  var person1=new Person({name:"Alfred",age:25,favoriteFoods:["Chocolates","Pie"]})
  person1.save(function(err,data){
    if(err)return console.error(err);
    done(null,data)
  })
};

What happened? Did you pass the test?

it did not work, i think it is about repl, but glitch is not forking from github or uploading folders

it is working but not passing the test

err: done is not a function, and if you log done it will give you undefined

Where you show a console.log(data) above, try done(null, data);.

1 Like

on freeCodeCamp repository on github , I found that this is the test code for this challenge …
if you look close to the code the test only accepts string where age = 28.
so your object should have the age=28 to pass

tests:
  - text: Creating and saving a db item should succeed
    testString: 'getUserInput => $.get(getUserInput(''url'') 
+ ''/_api/create-and-save-person'').then(data => { assert.isString(data.name, ''"item.name" should be a String'');
 assert.isNumber(data.age, ''28'', ''"item.age" should be a Number''); assert.isArray(data.favoriteFoods, ''"item.favoriteFoods" should be an Array''); 
assert.equal(data.__v, 0, ''The db item should be not previously edited''
); }, xhr => { throw new Error(xhr.responseText); })'

I forked your repl and made the change I suggested to you in my last reply and passed the tests.

I personally find the repl hard to work with for node/express projects. I highly recommend using Glitch instead.

1 Like

I have done them and did not pass, i will check the versions of the packages that i have used

It has nothing to do with the packages. Please update your repl as I have stated above and post a link to it, so I can validate there is not something else wrong instead.

code:

result:

even if comment calling the function on line 54, still the same