Skip to content
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

Cannot read properties of undefined (reading 'headers') #5004

Open
zucandu opened this issue Oct 5, 2022 · 4 comments
Open

Cannot read properties of undefined (reading 'headers') #5004

zucandu opened this issue Oct 5, 2022 · 4 comments

Comments

@zucandu
Copy link

zucandu commented Oct 5, 2022

Hello,

When I tried to update the axios to version 1.0.0, I get this error. It works fine with 0.27.2

Untitled

In the bootstrap.js, I used it with:

window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

Please advise. Thank you.

@JavierAgueroCL
Copy link

JavierAgueroCL commented Oct 6, 2022

I have the same issue

axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;

@thanhhungmk92
Copy link

I have the same issue . Help me, please
error
Info: laravel 7, vue 2
"laravel-mix": "^6.0.49",
"sass-loader": "^12.6.0",
"vue-loader": "^15.10.0",
"vue-template-compiler": "^2.7.12",
"webpack": "^5.23.0"

@Julian367
Copy link

Any solution for this?

@SneakyGerald
Copy link

SneakyGerald commented Nov 9, 2022

Seems a new wrapper function default was added, you can still access common props like this:

window.axios = require('axios');
window.axios.default.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

image

Worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants