NodeJS中POST请求的请求体为null
Request body is null for POST request in NodeJS
我有下面的代码。当我通过Postman发出Post请求时,我会得到未定义的req.body
。
Post Request是http://localhost:1702/es
。
正文:
{
"ip_a":"191.X.X.XX",
"pkts":34
}
和CCD_ 3。我也使用了application/x-www-form-urlencoded
,但得到了相同的结果。
我的应用程序是:
var express = require('express');
var es=require('./routes/es');
var app = express();
app.post('/es',es.postesdata);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
我收到请求正文为空的文件是:
exports.postesdata=function(req,res){
var body=req.body;
console.log(body);//Getting Undefined here
}
我是不是做错了什么?
express
按顺序运行中间件try:
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.post('/es',es.postesdata);
相关文章:
- NodeJS中POST请求的请求体为null
- Jquery ajax方法请求体为null,但poster工作正常
- AJAX请求中的JSON对象为Null或空
- 当请求时,我如何从文本区域删除null.GetAttribute为null,以及如何从servlet修改标签的可见性
- D3 Json请求获取XmlHttpRequest错误:访问控制允许原点不允许原点为null
- 使用 jQuery 的 Ajax GET 请求仅在 Safari 中返回 null
- HTML POST->重定向工作,XMLHTTPrequest->重定向不起作用(无法从null发出任何请求
- AJAX请求返回null
- 请求promise实现返回“null”
- 否'访问控制允许来源'标头存在于请求的资源上.起源'null'因此不允许访问
- AngularJS$http://.NET Web API-获取400(错误请求)或NULL POST操作方法参数
- 发送请求时可以使用urlencode null吗
- 在运行ajax请求时,无法将内部html设置为null
- ASP MVC基本AJAX Json请求返回null
- xmlHttpRequest无法在javascript控制台中从null发出任何请求
- 在soap请求中得到NULL而不是字符串值
- 在Soundcloud /tracks请求中BPM null(大多数时候)
- 在DELETE请求时参数为NULL
- 如果使用ajax请求数据,则在asp.net表单中提交时模型为null
- Facebook JS批处理请求返回Null