im trying to build this simple CMS with Restfull routes in Express.js ,
it was working just fine . then i tried to change it a lil bit so that my routes get neater(or not) .so i moved router.get('/new')
route below router.post('/')
route and it just stopped working as normal. when i try to get /new
route the request goes to router.get('/')
this is the related part of my app.js
(removed the unnessary parts)
var express=require('express'),
blogRoutes =require('./routes/blogs.js'),
app =express();
app.use('/blogs',blogRoutes);
and this is my blogs route in blogs.js
file (removed unnessary parts)
var express = require('express'),
router = express.Router();
router.get('/',function(req,res){...});
router.get('/:id',function(req,res){...});
router.post('/',function(req,res){...});
router.get('/new',function(req,res){...});
router.get('/:id/edit',function(req,res){...});
router.put('/:id',function(req,res){...});
router.delete('/:id',function(req,res){...});
so i want to know how does this work cuz i did not find anything usefull about the order of routes other than the RESTfull routes images on net that new is before create routes.yet it does make any sense why it can't process it correctly .