UNPKG
myparse
Version:
latest (0.0.1)
0.0.1
这是一个自己写的中间件,效果与body-parser一样!
myparse
/
index.js
12 lines
(11 loc)
•
239 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
const
querystring =
require
(
'querystring'
);
module
.
exports
=
function
(
req,res,next
){
var
str =
''
; req.
on
(
'data'
,
function
(
data
){ str+=data; }); req.
on
(
'end'
,
function
(
){ req.
body
= querystring.
parse
(str);
next
(); }) }