How does koa2+koa-bodyparser parse data in request payload form?

upload Picture Button in the form form, upload pictures are uploaded asynchronously using the upload component in layui. The backend can"t get the data, and ctx.request.body,ctx.params can"t get it either

.

clipboard.png

Aug.01,2021

Hello, landlord! You can try these two schemes, both of which can be solved at present.

  1. uses busboy to convert body body. Document Portal
  2. use middleware koa2-formidable , document Portal
    Code example:

        const formidable = require('koa2-formidable'); 
        app.use(formidable());
        const bodyparser = require('koa-bodyparser'); 
        app.use(bodyparser());

if it is helpful, please adopt ~

Menu