Skip to content

AxiosError: options must be an object #5142

@ckvv

Description

@ckvv

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions