Issue 1:
Describe the bug

When making a request to the server that generates a non 2xx status code, in node the response.data field is populated with the returned error message, in the browser, the field is consistently null for all requests (so far only tested with 4xx status codes)

To Reproduce

Using axios version 0.21.1

function testSearch_error2(client: AxiosInstance) {
client.get("/api/archive/search", {params: {start: "2020-01-25", long: -33.8523, lat: 151.2108}})
.then((resp) => {
if (!Array.isArray(resp.data)) {
return Promise.reject("response was not an array of results");
}

return resp.data as SearchResult[];
})
.catch(handleError);
}

function handleError(e: AxiosError): Promise<never> {
if (!(e?.response?.data)) {
console.dir(e);
}
return Promise.reject(e?.response?.data || e);
}

This searches a geospatial testing API, it will return a 401 error as the lat and long have been swapped and are out of range as a result.

The server returns plain strings as the response to a 400 error explaining the issue

Normally the result is passed out to the caller, and handleError ensures we pass out the specific error from the server, and falls back to the axios error if its something more complicated.

As mentioned, this behaves as expected when run in node, but when the same code is bundled for the browser, it always returns the axios error.

Using the console.dir call added while diagnosing this, I find that the response field is populated with the response details as I would expect. However, the data field is always null.

Inspecting the request in the network tab of the browser (mostly chrome in testing) shows the response, and its body is present, so I know this isn't the server failing to send a body with the response.

Expected behaviour

the response.data field to be populated with the body of the response

given some similar issues in react-native on stack overflow could this potentially be an inconsistency in the library when building for the browser v node?

Environment

Axios Version 0.21.1

Adapter XHR

Browser Chrome

Browser Version 87.0.4280.141

Node.js Version v10.16.0 (on an old laptop, this has reminded me to update

OS: Windows 10.0.19042 Build 19042

Additional Library Versions TypeScript 4.1.3, (webpack 5.15.0 and ts-loader 8.0.14 if relevant)

Additional context/Screenshots

Here you can see the response.data field being null

The relevant network tab entry

The network tabs response

Issue 2:
Seems to be because the config created by create is not being merged correctly

Describe the bug

F {message: 'options must be an object', name: 'AxiosError', code: 'ERR_BAD_OPTION_VALUE', stack: 'AxiosError: options must be an object\n at Objec…le:///Users/chenkai/Desktop/test/index.html:21:28'}
code
:
"ERR_BAD_OPTION_VALUE"
message
:
"options must be an object"
name
:
"AxiosError"
stack
:
"AxiosError: options must be an object\n at Object.Je [as assertOptions] (https://esm.sh/v96/axios@1.1.3/es2022/axios.js:3:10223)\n at B.request (https://esm.sh/v96/axios@1.1.3/es2022/axios.js:3:10983)\n at B.<computed> [as get] (https://esm.sh/v96/axios@1.1.3/es2022/axios.js:3:12121)\n at Function.get (https://esm.sh/v96/axios@1.1.3/es2022/axios.js:2:148)\n at file:///Users/chenkai/Desktop/test/index.html:21:28"
[[Prototype]]
:
Error

To Reproduce

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
<script type="module">
import Axios from 'https://esm.sh/axios';
import Qs from 'https://esm.sh/qs@6.11.0';

const instance = Axios.create({
paramsSerializer(params) {
return Qs.stringify(params, {arrayFormat: 'brackets'})
},
});

const res = await instance.get('https://jsonplaceholder.typicode.com/comments');
console.log(res);
</script>
</html>

Code snippet

No response

Expected behavior

No response

Axios Version

v1.1.3

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

No response

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response