Hi fellows! Getting this nasty error.
node:159192) UnhandledPromiseRejectionWarning: TypeError: callback is not a function
at C:\Users\ddobrikov\Desktop\cashierles\node_modules\mongoose\lib\connection.js:785:13
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:159192) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:159192) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
my code
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
require('dotenv/config');
//import routes
const postsRoute = require('./routes/posts');
app.use(bodyParser);
app.use('/posts', postsRoute);
//routes
app.get('/',(req, res) => {
res.send('We are on home');
})
// connect to a database
mongoose.connect(process.env.DB_CONNECTION,{ useUnifiedTopology: true }, {useNewUrlParser: true}, () => console.log('Connect to Db'));
//server
app.listen(3000);
const express = require('express');
const router = express.Router();
const Post = require('../models/Post');
router.get('/',(req, res) => {
res.send('We are on posts');
})
router.get('/specific',(req, res) => {
res.send('We are on admin');
})
router.post('/',(req, res) => {
console.log(req.body);
})
module.exports= router;
`type or paste code here`