![](/img/trans.png)
[英]Express body-parser req.body with formdata is empty object
[英]Passing formData to Express middleware, Req.body is returning empty object
我正在尝试从客户端获取 formData,
<!-- begin snippet: js hide: false console: true babel: false -->
/**
* @swagger
* /post_image_question:
* post:
* description: Post an image question
* parameters:
* - name: question
* description: Object of userId and questions array
* type: object
* in: formData
* properties:
* userId:
* type: string
* questions:
* type: array
* items:
* type: object
* properties:
* question_title:
* type: string
* question_description:
* type: string
* text_question:
* type: string
* code_snippet:
* type: string
* tagged_technologies:
* type: string
* image_question:
* type: string
* - name: image_question
* description: The question in form of image
* type: file
* in: formData
* consumes:
* - multipart/form-data
* responses:
* 200:
* description: Success
* 400:
* description:Bad Request
* 404:
* description:Not Found
* 500:
* description: Internal Server Error
*/
我正在将数据传递给中间件,我正在记录 req.body 并获取空对象,我可以做些什么来获取 formData 并将其转换为 json 数据
这是我的招摇文档
你需要在你的 index.js app.use(express.json());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.