如何从邮递员插件Node.js Express获取表单数据中的值 [英] how to get values in form-data from postman addon nodejs express

查看:110
本文介绍了如何从邮递员插件Node.js Express获取表单数据中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将node js与express框架,restful api一起使用. 我想在邮递员插件中使用表单数据"选项发布值.

I am using node js with express framework, restful api. I want to post values using 'form-data' option in postman addon.

我能够使用x-www-form-urlencoded选项发布值,并且能够获取req.body.usernamereq.body.email等值.这很好,但我还需要表单数据"选项.

I am able to post values using the x-www-form-urlencoded option and am able to get values like req.body.username, req.body.email, etc. This is working fine, but I need 'form-data' option also.

如果我使用表单数据"选项,那么我将无法获取帖子值,请帮助我如何在邮递员插件中使用此选项表单数据"来获取值.

If I use "form-data" option then I am not able to get the post values please help me how to get values using this option 'form-data' in postman addon.

推荐答案

我刚试过邮递员. 它以内容类型multipart/form-data形式发送标头.

I just tried postman. It sends the header as content type multipart/form-data.

您需要另一个软件包来处理.

You need another package to handle that.

它们在顶部的正文解析器存储库中链接. 例如: busboy

They are linked in body-parser repo at the top. For example: busboy, multiparty

这篇关于如何从邮递员插件Node.js Express获取表单数据中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆