Created
December 14, 2017 09:37
-
-
Save koenhoeijmakers/665e4aebaff7cd8189867778e2aed97c to your computer and use it in GitHub Desktop.
Axios interceptor to fix PUT (multipart/form-data) requests to a PHP back-end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Request interceptor that fixes PUT requests for php. >> https://bugs.php.net/bug.php?id=55815 | |
*/ | |
instance.interceptors.request.use((request) => { | |
if (request.method === 'put' && request.data instanceof FormData) { | |
request.method = 'post'; | |
request.data.append('_method', 'put'); | |
} | |
return request; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment