I'm trying to create an error message/log using "winston-mongodb" while sending it to my database. In my MongoDB Compass it created a log folder as expected, but there's no data in it.
Here's my code:
index.js
require("winston-mongodb");
winston.add(new winston.transports.MongoDB({ db: "mongodb://localhost/vidly_node_js" }));
genres.js
router.get("/", async (req, res) => {
throw new Error("Could not get the genres.");
const genres = await Genre.find().sort("name");
res.send(genres);
});
I'm supposed to be getting this:
But this is what I keep getting:
What am I missing???
Also "throw new Error("Could not get the genres.")" is making the code down below in my get function "unreachable". Maybe that's the reason? If so, what do I need todo to fix it? Because it’s giving me an error that says:
TypeError: common.clone is not a function
Upagrade winston-mongodb package to version 4+ to work with latest winston
https://github.com/winstonjs/winston-mongodb/issues/108
Winston 3 and mongodb 3 support is now in the winston-mongodb 4.x branch.
winston-mongodb 3.0 is not compatible with latest winston
https://github.com/winstonjs/winston-mongodb/tree/v3.0.1
Current version supports only mongodb driver version 2.x. If you want to use winston-mongodb with mongodb version 1.4.x use winston-mongodb <1.x.