【发布时间】:2016-03-10 22:22:58
【问题描述】:
我正在尝试获取此 URL 的结尾部分(在服务器端):
http://localhost:3000/insAds/D79htZY8DQ3YmcscE
我的意思是我想得到这个字符串:
D79htZY8DQ3YmcscE
有一个类似的问题:How to get the query parameters in Iron-router?
但没有一个答案对我有帮助!因为我在 URL 中没有查询参数。
我知道这些代码给了我想要的字符串:
this.params.id
和
Router.current().params.id
但这些代码仅在客户端有效!我想在服务器端获取那个字符串!
最后我尝试获取该字符串并在此处使用:
Ads.before.insert(function(userId, doc) {
//console.log(this.params.id);
doc._categoryId = this.params.id;
doc.createdAt = new Date();
doc.createdBy = Meteor.userId();
});
【问题讨论】:
标签: meteor iron-router