-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property '0' of undefined #46
Comments
Hi, thanks for reporting this issue. The express.Router documentation defines router.get like this: const express = require("express")
const app = express()
const router = express.Router()
router.get(function (req, res) {
res.send("test")
})
app.use("/", router)
app.listen(3000) (Opening Use const express = require("express")
const app = express()
const router = express.Router()
router.get("/", function (req, res) { // <- you can't omit the path when calling .METHOD
res.send("test")
})
app.use(router) // <- you can omit the path when calling .use
app.listen(3000) We try to act as a drop-in replacement and try to stay as close to the original behavior as possible, therefor i might provide a "fix" so we don't crash. Documentation: If anything is still unclear don't hesitate to ask |
Hi, So the bug is not really a bug :) The crash is useful to detect the wrong usage , eventually the user may get warned of the wrong usage, but is really an edge case Thanks |
const router = require('express-promise-router')() // We get that error typically not because of 'express-promise-router', but others errors like invalid function, spelling mistakes.... etc |
I have encountered this error when trying the documented and valid router.route() usage as shown here
if you try to give it a sub route so that promise router doesnt error i.e. |
@megamit could you open a new issue? I'm not sure if this is related to the current one. |
Hi
I have a snippet like this (also using
express-promise-router
from master)Running tests I get
Maybe I am not using properly or should it be a managed case?
Thanks
The text was updated successfully, but these errors were encountered: