DEV Community

Chidiebere Chukwudi
Chidiebere Chukwudi

Posted on

Empty requests data with multipart/form-data when using fetch api

It took me quite some time to resolve this isssue. It was an issue with formData and laravel/php not being able to detect the request payload when I dd or dump the request to check.

There is (and I believe) other solutions but I think this will save you the need to do "messy" workarounds.

Here you go:

DO NOT specify the Content-Type header yourself, when trying to make such a multipart request. That header needs to include the boundary value (so that the receiver will know how to parse this request) - if you specify it yourself, as just multipart/form-data, then that will be missing.

These…

Latest comments (0)