微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

没有身体分析器的表达在哪里输入JSON?

我了解人体分析仪及其作用.我很好奇,知道使用Express时请求中的数据在哪里.在主体解析器解析输入之前,存在哪种格式.

// parse urlencoded types to JSON
app.use(bodyParser.urlencoded({
    extended: true
}));

// parse various different custom JSON types as JSON
app.use(bodyParser.json({ type: 'application/*+json' }));

// parse some custom thing into a Buffer
app.use(bodyParser.raw({ type: 'application/vnd.custom-type' }));

// parse an HTML body into a string
app.use(bodyParser.text({ type: 'text/html' }));

如果不使用这些数据,数据将在哪里?它将以哪种格式提供?

解决方法:

Node documentation对此进行了全面介绍.

The request object that’s passed in to a handler implements the ReadableStream interface. This stream can be listened to or piped elsewhere just like any other stream. We can grab the data right out of the stream by listening to the stream’s ‘data’ and ‘end’ events.

Express确实在对Node.js HTTP服务器功能应用扩展,包括扩展本机的Request和Response对象.因此,您也可以像对待native request object as well一样对待Express请求

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐