AxiosError: options must be an object
See original GitHub issueSeems 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
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:11
Top Results From Across the Web
Axios return Cannot GET /[object%20Object] when calling ...
This means useParams(); is returning an object with the property user_id inside it. So what you want is to extract that property.
Read more >name: 'axioserror', code: 'err_bad_request'
AxiosError : Request failed with status code 400 (in React JS) ... axios/axiosAxiosError: options must be an object#5142. Created 2 months ago.
Read more >解决AxiosError: options must be an object ...
{message: 'options must be an object', name: 'AxiosError', code: 'ERR_BAD_OPTION_VALUE', stack: 'AxiosError: options must be an object\n at ...
Read more >storyblok/react
The React plugin you need to interact with Storyblok API and enable the ... Add all your components to the components object in...
Read more >Request Config | Axios Docs
These are the available config options for making requests. ... parameters to be sent with the request // Must be a plain object...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
https://github.com/axios/axios/blob/9d4b016ddedf835bfd838b63e50af14d84e2813e/lib/helpers/buildURL.js#L47
The original spelling should be changed to
This is a breaking update, but the documentation doesn’t say ,and it contains a previous wrong usage
It’s working after all, just had to tweak something in a custom middleware I had. Thanks @J3m5 for the tip.