R
R
retyui2015-02-08 12:43:13
JavaScript
retyui, 2015-02-08 12:43:13

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

I navigate in the browser to l/users/blablbabla
in the debugger object req :
ad7c011d4ca740888476fd94477648c6.PNG

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question