【发布时间】:2016-08-27 20:42:09
【问题描述】:
我已经阅读了关于名为 body-parser 的 npm 打包的解决方案,但如果我能找到另一种方法,我不想使用它。我只是想解析节点中的 POST 数据。
我有一个这样的 ajax 函数:
$.ajax {
url: '/foo',
method: 'POST',
data: {foo: "foo", bar: "bar"}
}
类似:
app.post('/foo', function(req, res) {
var postFoo = req.foo; // How do I do this?
});
【问题讨论】:
-
您告诉过您不想使用 body-parser 但接受了一个告诉您使用它的答案??
-
我应该更仔细地阅读,因为我的回答在技术上是错误的!为什么不想使用 body-parser?
标签: javascript ajax node.js post