post请求参数处理
const bitchAdd = (request, response) => {
let params;
request.on('data', function (chunk) {
params = chunk
console.log('chunk', params);
})
request.on('end', function () {
console.log('params', params.toString(), );
console.log('处理后params', querystring.parse(params.toString()));
response.end(JSON.stringify({
code: 0,
data: {
list: querystring.parse(params.toString())
}
}))
})
}
chunk <Buffer 6e 61 6d 65 3d 59 61 6e 26 68 6f 62 62 79 3d 73 77 69 6d 6d 69 6e 67 26 63 72 65 61 74 65 44 61 74 65 3d 32 30 32 33 32 2d 30 33 2d 32 34>
params name=Yan&hobby=swimming&createDate=20232-03-24
处理后params [Object: null prototype] {
name: 'Yan',
hobby: 'swimming',
createDate: '20232-03-24'
}