throw new error_1.MongoParseError(`${optionWord} ${Array.from(unsupportedOptions).join(', ')} ${isOrAre} not supported`);
This error is gen whenever I go to start up my server for testing
const express = require("express");
const app = express();
const morgan = require("morgan");
const bodyParser = require("body-parser");
const mongoose = require('mongoose');
//sets names for the different areas of the projects
const productRoutes = require('./api/routes/products');
const orderRoutes = require('./api/routes/orders');
mongoose.connect('mongodb+srv://24williamharris:' +
process.env.MONGO_ATLAS_PW +
'@cluster0.pxgod.mongodb.net/Cluster0?retryWrites=true&w=majority',
{
useMongoClient: true
});
//Logs stuff in terminal
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
//Prevents Cors Errors
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*")
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept, Authorization"
);
if (req.method === 'OPTIONS'){
res.header('Access-Control-Allow-Methods', 'PUT, POST, PATCH, DELETE, GET');
return res.status(200).json({});
}
next();
});
//routes the requests to other areas of the project
app.use('/products', productRoutes);
app.use('/orders', orderRoutes);
app.use((req, res, next) => {
const error = new Error('Not found');
error.status = 404;
next(error);
});
app.use((error, req, res, next) => {
res.status(error.status|| 500);
res.json({
error: {
message: error.message
}
});
});
module.exports = app;
Here is my source code for the app.js file
I wasn’t getting it a bit earlier, then I started adding things to the project with mongoose, and I cant find where the issue keeps originating from.
Anyone on this forum see where my issue lies?