When I attempt to run nodemon index.js in the terminal, I encounter an error message that is quite confusing and unclear to me. Can someone please provide some guidance on how to resolve this issue?
Below is the content of index.js:
const express = require('express');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
var app = express();
var router = require('./services/router');
mongoose.connect('mongodb://localhost:apiAuth');
app.use(morgan('combined'));
app.use(bodyParser.json());
app.use('/v1', router);
var PORT = process.env.PORT || 3000;
var HOST = process.env.HOST || '127.0.0.1';
console.log('Listening on', HOST, PORT);
app.listen(PORT, HOST);
And here is the content of services/router.js:
var router = require('express').Router();
function protected(req, res, next) {
res.send('Here is the secret!');
}
router.route('/protected')
.get(protected);
module.exports = router;
This is the output from the Terminal:
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] starting `node index.js`
Listening on 127.0.0.1 3000
(node:29104) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Slash in host identifier
(node:29104) [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.