我正在尝试在我的Meteor应用程序中创建一个简单的REST API。使用doc
中的确切示例Router.route('/webhooks/stripe', { where: 'server' })
.get(function () {
// GET /webhooks/stripe
})
.post(function () {
// POST /webhooks/stripe
})
.put(function () {
// PUT /webhooks/stripe
})
抛出错误:
=> Exited with code: 8
W20160116-16:39:15.200(-8)? (STDERR)
W20160116-16:39:15.201(-8)? (STDERR) /Users/me/.meteor/packages/meteor-tool/.1.1.10.1b51q9m++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20160116-16:39:15.201(-8)? (STDERR) throw(ex);
W20160116-16:39:15.201(-8)? (STDERR) ^
W20160116-16:39:15.204(-8)? (STDERR) TypeError: Object [object Object] has no method 'get'
W20160116-16:39:15.205(-8)? (STDERR) at lib/router.js:9:4
W20160116-16:39:15.205(-8)? (STDERR) at /Users/me/repo/.meteor/local/build/programs/server/app/lib/router.js:25:4
W20160116-16:39:15.205(-8)? (STDERR) at /Users/me/repo/.meteor/local/build/programs/server/boot.js:242:10
W20160116-16:39:15.205(-8)? (STDERR) at Array.forEach (native)
W20160116-16:39:15.205(-8)? (STDERR) at Function._.each._.forEach (/Users/me/.meteor/packages/meteor-tool/.1.1.10.1b51q9m++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20160116-16:39:15.205(-8)? (STDERR) at /Users/me/repo/.meteor/local/build/programs/server/boot.js:137:5
有什么想法吗?
答案 0 :(得分:0)
在我看来,你可能错过了安装铁路由器?
.. at /Users/me/repo/.meteor/local/build/programs/server/app/lib/router.js:25:4
这似乎表明Router
仍然是流星自己的路由器,而不是生活在某处的铁路由器
/Users/me/repo/.meteor/local/build/programs/server/packages
确保你跑了:
meteor add iron:router
您可以使用meteor list
查看已安装的软件包。