小爷我也是醉了。。。本来是畅通快意,一路无阻,西天大道,畅意无限~~
遇到parser error 《》》《《《》《》《》《《《《》《《》》《》》》》《》》《》《》《《《》《》
connect deprecated multipart: use parser (multiparty, busboy, formidable) npm mo
dule instead node_modules\express\node_modules\connect\lib\middleware\bodyParser
.js:56:20
code:【未更改】
var express = require('express');
var redis = require('./models/redis.js');
var app = express();
app.use(express.bodyParser());
原因是需要代替bodyparser。。。但是我翻遍中间件并无代替滴。。。
小爷机智,不看中间件,搜parser。。。尼玛,版本0.0.1
改了之后就出现这个了。。。
body-parser deprecated bodyParser: use individual json/urlencoded middlewares ap
p.js:8:9
code:【初代火影】
var express = require('express');
var redis = require('./models/redis.js');
var bodyParser=require('body-parser');
var app = express();
app.use(bodyParser());
有了模块就可以看实例了,网上也有牛哥解答。
answer:
It means that using the bodyParser() constructor has been deprecated, as of 2014-06-19.
app.use(bodyParser()); //Now deprecated~~~~~~~过期了。。。尼玛,新版本也过期。小爷入了桃花林了。
You now need to call the methods separately
app.use(bodyParser.urlencoded());
app.use(bodyParser.json());
And so on.
If you're still getting a warning with urlencoded you need to use
app.use(bodyParser.urlencoded({
extended: true
}));
The extended config object key now needs to be explicitly passed, since it now has no default value.
code:【二代火影】
var express = require('express');
var redis = require('./models/redis.js');
var bodyParser=require('body-parser');
var app = express();
app.use(bodyParser.urlencoded());
app.use(bodyParser.json());
body-parser deprecated undefined extended: provide extended option node_modules\
body-parser\index.js:105:29
这个就简单了,他说没有定义,我也没用到这个解析块。。。索性注释掉。。。//app.use(bodyParser.urlencoded());
request .post实例
```js
var request = require('request');
request('http://www.google.com', function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
});
```
```js
request.post({
url:"http://127.0.0.1:3017",
json:{
"owner":"bottle"+i,
"type":"male",
"content":"content"+i
}
```
e ...
[三代火影]超难受...
160...parser error...
上边这个问题,我研究了很久,我的数据库是redis,nodejs环境,搭建的服务器监听port为3500,
解析错误,我就去找API文档,以为引用什么的错了。
网上什么port全tm扯淡...
命运和我开了一个天大的玩笑~真的是port【服务器监听为3500,数据库使用3500】
总结了一下,关于parser【导入为body-parser包】“parser error ”大部分都是port错误...