Home News Video Node.js Blog App REST API with MongoDB

42 COMMENTS

  1. 10:00 The useCreateIndex option has been deprecated for a while and removed as of the Mongoose 6 release per No More Deprecation Warning Options:

    useNewUrlParser , useUnifiedTopology , useFindAndModify , and useCreateIndex are no longer supported options. Mongoose 6 always behaves as if useNewUrlParser , useUnifiedTopology , and useCreateIndex are true , and useFindAndModify is false .

  2. {

    "errors": {

    "username": {

    "name": "ValidatorError",

    "message": "Path `username` is required.",

    "properties": {

    "message": "Path `username` is required.",

    "type": "required",

    "path": "username"

    },

    "kind": "required",

    "path": "username"

    },

    "email": {

    "name": "ValidatorError",

    "message": "Path `email` is required.",

    "properties": {

    "message": "Path `email` is required.",

    "type": "required",

    "path": "email"

    },

    "kind": "required",

    "path": "email"

    },

    "password": {

    "name": "ValidatorError",

    "message": "Path `password` is required.",

    "properties": {

    "message": "Path `password` is required.",

    "type": "required",

    "path": "password"

    },

    "kind": "required",

    "path": "password"

    }

    },

    "_message": "Users validation failed",

    "name": "ValidationError",

    "message": "Users validation failed: username: Path `username` is required., email: Path `email` is required., password: Path `password` is required."

    }
    i got the error in 26:27

  3. I wrote the exact code that you wrote but when I was testing the register api it was showing error even after using express.json(). Can anyone give me any solution. I was using thunder client for the testing.

  4. Yeah, finally complete this part. Thanks a lot, Lama 先生(sensei). Some parts were a bit difficult and as of April 2023, some parts of the code didn't work properly. So if anyone gets stuck, can see the other comments for solving. Hope can complete the last part of the series properly.

  5. Hello Lama Dev, I have been following through your tutorial and I must acknowledge that your method of instructing is topnotch. Thank you so much for the outstanding content you are giving out.

  6. Around 34:00:00 I faced errors while trying wrong credentials multiple times in a row.
    "Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client".
    I had to change the login route code to this, notice the use of return:
    router.post('/login', async (req, res) => {
    try {
    const user = await User.findOne({ username: req.body.username });
    if (!user) {
    res.status(400).json('Wrong credentials!');
    return;
    }
    const validated = await bcrypt.compare(req.body.password, user.password);
    if (!validated) {
    res.status(400).json('Wrong credentials!');
    return;
    }
    const { password, …others } = user._doc;
    res.status(200).json(others);
    } catch (err) {
    res.status(500).json(err);
    }
    });
    Hope this helps someone else 🚀

LEAVE A REPLY

Please enter your comment!
Please enter your name here