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

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

@camperextraordinaire 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

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 have done them and did not pass, i will check the versions of the packages that i have used

code:

result:

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

here is the repl:

I have passed the tests, the reason was using arrow function as a callback.

We have to use normal functions to pass.