GaryChangCN / koa2-formidable

koa2 middleware for formidable
Other
17 stars 1 forks source link

Can not receive array. #4

Open jackchoumine opened 2 years ago

jackchoumine commented 2 years ago

verssions:

"koa": "^2.13.1",
    "koa-bodyparser": "^4.3.0",
    "koa2-formidable": "^1.0.3",

send array json with fetch:

fetch(url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
    body: JSON.stringify([{name:'test'}]),
  })
    .then(res => res.json())
    .then(res => {
      console.log(res)
    })
    .catch(e => {
      console.log(e)
    })

app:

app.use(formidable())
app.use(
  bodyParser({
    formLimit: '50mb',
    jsonLimit: '50mb',
    textLimit: '50mb',
  })
)

receive a object from endpoint .

const { body } = ctx.request // body is object

when i remove app.use(formidable()) body is array.

marte1309 commented 1 year ago

i have the same issue