DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,274 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
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…

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.