Having trouble receiving a response from the server after making get/post requests. I've tried adjusting the order of functions in index.js without success. I also attempted to send a post request using Postman to localhost:8080/register, but the request seems to be stuck.
I suspect that it could be caused by middleware preventing the request from going through. I've even tried commenting out all app.use statements except for authRouter, but it doesn't seem to resolve the issue.
Index.js
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const db = require('./config/dbConfig');
const app = express();
const authRouter = require('./router/authRouter');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cors());
app.use(authRouter);
const PORT = process.env.PORT || 8080;
db.sync({ force: true }).then(() => {
app.listen(PORT, () => console.log(`Server up and running @ ${PORT}`));
});
authRouter.js
const { Router } = require('express');
const authController = require('../controllers/authController');
const router = Router();
router.get('/register', () => {
authController.register_get;
});
router.get('/login', () => {
authController.signin_get;
});
router.post('/register', () => {
authController.register_post;
});
router.post('/login', () => {
authController.signin_post;
});
module.exports = router;
authController.js
module.exports.register_get = (req, res) => {
res.send('signup');
};
module.exports.register_post = (req, res) => {
res.send('signup');
};
module.exports.signin_get = (req, res) => {
res.send('signup');
};
module.exports.signin_post = (req, res) => {
res.send('signup');
};