[Solved] Why get call to node.js server doesn’t getting any answer

Uri Gross Asks: Why get call to node.js server doesn’t getting any answer
I am sending a simple get request (without any params) through chrome/postman When and get no reaction.

I expected to get an answer “cannot get” on sending get request to localhost:3030 I expect to get the jason file on my db when I send a get request to localhost:3030/api/task In both cases I get the “loading /thinking” circle and nothing happens.

No error messages.

I implamented a console.log on the task controller file and it’s even not reaching there.

I am attaching the server.js file. I suspect something is wrong there. I don’t want to overload this question.

Code:
const cors = require('cors')
const path = require('path')
    //const expressSession = require('express-session')

const app = express()
const http = require('http').createServer(app)

// const session = expressSession({
//         secret: 'coding is amazing',
//         resave: false,
//         saveUninitialized: true,
//         cookie: { secure: false }
//     })
//Express App Config
app.use(express.json())
    //app.use(session)

if (process.env.NODE_ENV === 'production') {
    app.use(express.static(path.resolve(__dirname, 'public')))
} else {
    const corsOptions = {
        origin: ['http://127.0.0.1:8080', 'http://localhost:8080', 'http://127.0.0.1:3000', 'http://localhost:3000'],
        credentials: true
    }
    app.use(cors(corsOptions))
}
const taskRoutes = require('./api/task/task.routes')
    //const { connectSockets } = require('./services/socket.service')

// routes
const setupAsyncLocalStorage = require('./middlewares/setupAls.middleware')
app.all('*', setupAsyncLocalStorage)

// app.get('/api/setup-session', (req, res) => {
//     req.session.connectedAt = Date.now()
//     console.log('setup-session:', req.sessionID);
//     res.end()
// })

app.use('/api/task', taskRoutes)
    //connectSockets(http, session)
    //connectSockets(http);


// Make every server-side-route to match the index.html
// so when requesting http://localhost:3030/index.html/car/123 it will still respond with
// // our SPA (single page app) (the index.html file) and allow vue/react-router to take it from there
// app.get('/**', (req, res) => {
//     res.sendFile(path.join(__dirname, 'public', 'index.html'))
// })

const logger = require('./services/logger.service')
const port = process.env.PORT || 3030
http.listen(port, () => {
    logger.info('Server is running on port: ' + port)
})```

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.