Created
November 1, 2011 12:17
-
-
Save artcommacode/1330404 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//app.js | |
var users = app.resource('users', require('./controllers/users')); | |
users.map('get', '/login', users.login); | |
//users.js | |
exports.login = function(req, res){ | |
res.end('login'); | |
}; | |
//error | |
TypeError: undefined is not a function | |
at CALL_NON_FUNCTION (native) | |
at /srv/www/node/ithrowu/node_modules/express-resource/index.js:152:7 | |
at callbacks (/srv/www/node/ithrowu/node_modules/express/lib/router/index.js:272:11) | |
at param (/srv/www/node/ithrowu/node_modules/express/lib/router/index.js:246:11) | |
at param (/srv/www/node/ithrowu/node_modules/express/lib/router/index.js:243:11) | |
at pass (/srv/www/node/ithrowu/node_modules/express/lib/router/index.js:253:5) | |
at Router._dispatch (/srv/www/node/ithrowu/node_modules/express/lib/router/index.js:280:4) | |
at Object.handle (/srv/www/node/ithrowu/node_modules/express/lib/router/index.js:45:10) | |
at next (/srv/www/node/ithrowu/node_modules/express/node_modules/connect/lib/http.js:201:15) | |
at /srv/www/node/ithrowu/node_modules/express/node_modules/connect/lib/middleware/session.js:323:9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// looks like objects don't map like i assumed they would
// this works pretty well, probably better to define the require up at top though ... maybe a better way of defining controllers?
var users = app.resource('users', require('./controllers/users'));
users.map('get', '/login', require('./controllers/users').login);