-
Notifications
You must be signed in to change notification settings - Fork 130
Open
Description
Hello,
I am unable to parse the multipart form data sent using new FormData from frond end, it works fine in the postman form data. I am new to koa, can anyone help me here
Environment Information
- koa-body: 4.2.0
- Koa: 2.13.4
- Node.js: 16.13.0
Current Behavior
i am using below code to pass the multipart option to middleware
`const KoaRouter = require("@koa/router");
const koaBody = require("koa-body");
const Api = require("./apis/apis");
const app = new KoaRouter({ prefix: "/" });
app.post(
"query-update-profile-picture",
koaBody({
multipart: true,
formLimit: 1024 * 1024,
formidable: {
maxFileSize: 1024 * 1024
}
}),
Api.updateProfilePicture
);`
My server.js is
`const Koa = require("koa");
const routes = require("./routes");
const app = new Koa();
app.use(routes.routes());`
and in my upload function, if a console
`console.log(ctx.request.files);
console.log(ctx.request.body);`
it gives me below response for body, file is undefined....
it is not parsing the request body

My front end handler function is
`const imageData = new FormData();
imageData.append("profile_picture", target.files[0]);
imageData.append("id", id);
await updateProfileImage(imageData);`
UpdateProfileImage function
`const response = await axios.post(
url,
body
);`
Can any one help me?
mkamalkayani and gtk2k
Metadata
Metadata
Assignees
Labels
No labels