I am sending form data with a basic POST request:
const formData = new FormData();
formData.append('id', '123');
const res = await fetch('./handler', { method: 'POST', body: formData });
const json = await res.json();
handler.js
export default async function handler(req, res) {
console.log(req.body.id);
...
}
The code above will log undefined
. When logging req.body
the result is something that definitely needs decoding:
------WebKitFormBoundary
Content-Disposition: form-data; name="id"
123
------WebKitFormBoundary --
How do I read the data passed?