DEV Community

Discussion on: Build a Node.js/Express API with MongoDB

Collapse
 
edin profile image
Edin • Edited

Add the line

module.exports = mongoose.model("Book", BookSchema);

to book.model.js

I fixed it above, sorry for that.

Collapse
 
thedvlpr profile image
Sophie

Thanks for your prompt reply Edin! I appreciate that.

One more thing, Edin, would you pls fix this part of code, otherwise someone will run into a ReferenceError: next is not defined :-) Thanks again!


book.save((next, err) => {
        if (err) {
            return next(err);
        }
        res.send('Book created successfully!');
    });