I spend 3 hours trying to understand that. All the blog posts related to this topic do not work. Netlify Functions V2 uses Request API. I used Node.js v20 to parse FormData values in multipart/form-data
requests. You can see how easy it is with the example below. This function returns form data values as JSON in response.
export default async function (event) {
const data = await event.formData();
const fields = {};
for (const pair of data.entries()) {
fields[pair[0]] = pair[1];
}
return new Response(JSON.stringify(fields), { status: 200 });
}
I hope this helps you. Have nice coding!
Top comments (0)