【发布时间】:2015-07-03 08:06:00
【问题描述】:
我想在流星中使用来自 Template.event 的 post 参数进行 HTTP.call。我已经在 Iron:Router 中定义了我当前应用程序的路由。 路线正在接听电话,但我无法获取发布参数。该路由是服务器端路由,并使用以下命令返回 pdf 内容:
Template.eStatement.events({
'click .pdf': function (event, template){
event.preventDefault();
param = Some json object that I need to pass as post parameter.
HTTP.call("POST", '/statement', JSON.stringify(param),
function(error, result){ if(result){ // } if(error){ // } //done(); }); }});
这是我的路线(我正在使用 iron:route 包为流星)
Router.route('/statement', function () {
var param = JSON.parse(this.params.query.param);
/** Get the pdf content by calling the api
/** Write the content back :
this.response.writeHeader('200', {
'Content-Type': 'text/html',
'Content-Disposition': "inline",
});
this.response.write('pdfcontent');
this.response.end(); },{where: 'server'}
【问题讨论】:
-
请输入代码。不看代码就很难帮助排错。
-
这很难读。请编辑您的帖子,并阅读如何在 StackOverflow 上的帖子中格式化代码。 (选择您的代码并点击 { } 大括号图标)。
-
对不起。这是我关于堆栈溢出的第一篇文章。不习惯格式化。
-
我希望编辑后的帖子足够清晰。
-
您能告诉我您将在
HTTP.call中使用哪些(或多少个)参数吗?
标签: meteor