Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs Express,主体解析器不解析表单数据+;对象(使用Angular.js$resource)_Angularjs_Node.js_Parsing_Express_Body Parser - Fatal编程技术网

Angularjs Express,主体解析器不解析表单数据+;对象(使用Angular.js$resource)

Angularjs Express,主体解析器不解析表单数据+;对象(使用Angular.js$resource),angularjs,node.js,parsing,express,body-parser,Angularjs,Node.js,Parsing,Express,Body Parser,我正在学习angular.js$resource。就像文档中的例子一样,我有一个自定义方法 // some stuff {charge: {method:'POST', params:{charge:true}} //declaring custom method // some stuff // and then call the this method card.$charge({amount:9.99}); // It makes POST: /user/123/card/456?am

我正在学习angular.js$resource。就像文档中的例子一样,我有一个自定义方法

// some stuff
  {charge: {method:'POST', params:{charge:true}} //declaring custom method
// some stuff
// and then call the this method
card.$charge({amount:9.99});
// It makes POST: /user/123/card/456?amount=9.99&charge=true {id:456, number:'1234', name:'J. Smith'}
问题在于我的express应用程序只解析对象,未命中
amount=9.99&charge=true
。但如果我只发送
amount=9.99&charge=true
wihtout对象(而不是通过angular的$resource),它的解析就可以了。如果我只发送对象,则相同。但不是两者都有。 所以我不能得到真正需要的
charge=true
。我甚至可能得不到对象,但Angular的$resource在默认情况下会附加它,所以我不知道在调用自定义方法时如何防止附加对象

我正在使用: express 4正文分析器,带配置:

app.use(bodyParser.urlencoded({
   extended: true
}));
app.use(bodyParser.json());
app.use(methodOverride());
multer


所以,亲爱的社区,请帮助。我要休息两个小时。

根据你的$resource声明

card.$charge({amount:9.99});
这将发送一个带有查询的POST请求:
amount=9.99&charge=true
,以访问那些正在快速使用的
req.query.amount
req.query.charge