Answer the question
In order to leave comments, you need to log in
Express 4.11.2 routers error!?
ObjectID = require('mongodb').ObjectID
express = require 'express'
router = do express.Router
User = require('../models/user').User
HttpError = require('../error').HttpError
router.get '/',(req, res, next)->
User.find {},(err,users)->
if err then return next err
res.json users
router.all '/:id',(req, res, next)->
try
id_ = new ObjectID '54d64059d4aa80183992b585'#(req.param.id)
catch
next 404
return
User.findById id_,(err,user)->
if err then return next err
if not user
return next(404)
res.json user
module.exports = router
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question