New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default 'json' responseType is not applied to requests #3116
Comments
I am running into a same issue with axios i have the config with Removing the |
In the meantime, this configuration is a workaround:
|
Thanks @berniegp, but it persists with that param set. The docs also say that To get the request to work, I have to remove the Here is my code: import {store} from '../store';
import {getAPIBaseUrl} from './app_urls';
import axios from "axios";
const defaultOptions = {
baseURL: getAPIBaseUrl(),
responseType: "json",
headers: {
'Content-Type': 'application/json'
},
crossDomain: true
};
// Create instance
const instance = axios.create(defaultOptions);
// Set the AUTH token for any request if authenticated
instance.interceptors.request.use(function (config) {
const token = store.getState().session.token;
if (token) {
config.headers = {...config.headers, ...token}
}
return config;
});
export default instance; |
I think this is an issue that has occurred due to us changing axios to allow the browser to decide the response type, since we have gone back and forth a lot on this we will probably not make any new changes till we cut a v1. |
Describe the bug
The documentation states:
However, the
responseType
ofXMLHttpRequest
is left unset (same as"text"
) by default instead of being set set to'json'
. This causes an empty response body to become""
instead ofnull
as expected from the XMLHttpRequest specification :To Reproduce
Create a request with the XHR adapter where the server responds with an empty body. Then
response.data === ""
.Expected behavior
response.data === null
(through a defaultrequest.responseType = 'json'
).Environment
Additional context/Screenshots
The text was updated successfully, but these errors were encountered: