I am learning mern stack and was watching a tutorial on youtube code camp.org. I followed along with tutor code but his code is working and mines not working. my express server is not connected or something. I started nodemon server.js
[nodemon] 2.0.19
[nodemon] to restart at any time, enter rs
[nodemon] watching path(s): .
[nodemon] watching extensions: js,mjs,json
[nodemon] starting node server.js
[nodemon] clean exit - waiting for changes before restart
but i am not getting the console message which i should get if i am connected to express server.
this is my index.js file
import app from '../server'
import mongodb from "mongodb";
import dotenv from "dotenv";
dotenv.config();
const MongoClient = mongodb.MongoClient;
const port = process.env.PORT || 8000;
MongoClient.connect(process.env.RESTREVIEWS_DB_URI, {
poolSize: 50,
wtimeout: 2500,
useNewUrlParse: true,
}).catch(err => {
console.error(err.stack)
process.exit(1)
})
.then(async client => {
app.listen(port, ()=>{
console.log(`listening on ${port}`)
})
})
and in case you need this is my server.js file
import express from "express"
import cors from "cors"
import restaurants from "./api/restaurants.route.js"
const app = express()
app.use(cors())
app.use(express.json())
app.use("/api/v1/restaurants",restaurants)
app.use("*", (req,res)=>res.status(404).json({error: "not found"}))
export default app
my specified port is 5000
kindly i am a beginner guide me what should i do
thank you!