app.use(express.json) doesn’t work inside mongoose.connect

You just need to put the experss.json() code above the line where you are importing/defining the route.

    .then(() => {
        app.use('/items', itemsRouter);

        app.listen(3000, () => {
            console.log('server started');
    .catch(err => {
        console.log("error, database not connected or:", err.message);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top