Created
September 16, 2022 04:35
-
-
Save Calvin-Huang/4f2fa7b2552a7b0777f4f96d8c0cfd25 to your computer and use it in GitHub Desktop.
simple example to transform response from underscore to camelCase in axios interceptor
This file contains 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
// Add a response interceptor | |
axios.interceptors.response.use(function (response) { | |
// Any status code that lie within the range of 2xx cause this function to trigger | |
// Do something with response data | |
return { | |
...response, | |
data: humps.camelizeKeys(response.data), | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment