Reputation: 126
I only got /
route to work. From what I see most problems like mine are that routers are mounted to some path like /auth
or /user
. Now I tested my default router that is mounted to /
and its still not working. This is my code:
import indexRouter from './routes/index'
app.use('/',indexRouter);
and in my routes/index
import { Router } from 'express';
const router = Router();
router.get('/',(req,res)=>{
res.send(true);
})
router.get('ping',(req,res)=>{
res.send('pong')
})
export default router;
when I visit /
its working, and ping
is not working.
Upvotes: 0
Views: 1898
Reputation: 1169
Please change like below.
FROM
router.get('ping',(req,res)=>{
res.send('pong')
})
TO
Please add / into routing url.
router.get('/ping',(req,res)=>{
res.send('pong')
})
Upvotes: 5