// Require packages and set the port
const express = require('express');
const port = 3002;
const app = express();
const bodyParser = require('body-parser');
const routes = require('./routes/routes');
// Use Node.js body parsing middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true,
}));
app.get('/', (request, response) => {
console.log(`URL: ${request.url}`);
response.send({
message: 'Grades'}
);
});
// Start the server
const server = app.listen(port, (error) => {
if (error) return console.log(`Error: ${error}`);
console.log(`Server listening on port ${server.address().port}`);
});
// Export the router
module.exports = router;
I'm setting up a new route and got some issue with code. It's my first post here, and I'm starting with programming, so it would be great if you show some understanding. :) I suppose that mistake is in the line with app.get where I have to put also routes(app);
, but unfortunately, I don't know how to use it. There might be a problem with the last line, I might just use it in the wrong way.