I cannot see my server on my local machine. i get the following error: Cannot GET /post.
My client server is running fine. However I am not able to see my server side.
post.js
import express from 'express';
const router = express.Router();
router.get('/', (req, res) => {
res.send('THIS WORKS!')
});
export default router;
index.js
import express from 'express';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import cors from 'cors';
import postRoutes from './routes/post.js';
const app = express();
app.use('/posts', postRoutes);
app.use(bodyParser.json({ limit: '30mb', extended: true }))
app.use(bodyParser.urlencoded({ limit: '30mb', extended: true }))
app.use(cors());
const CONNECTION_URL = 'mongodb+srv://***:***@***.net/?retryWrites=true&w=majority';
const PORT = process.env.PORT|| 9999;
mongoose.connect(CONNECTION_URL, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => app.listen(PORT, () => console.log(`Server running on port: ${PORT}`)))
.catch((error) => console.log(error.message));