Skip to content

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

Closed

Description

@zucandu

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.

Activity

  1. JavierAgueroCL commented on Oct 6, 2022

    @JavierAgueroCL

    I have the same issue

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

  2. thanhhungmk92 commented on Oct 12, 2022

    @thanhhungmk92

    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"

  3. Julian367 commented on Oct 28, 2022

    @Julian367

    Any solution for this?

  4. SneakyGerald commented on Nov 9, 2022

    @SneakyGerald

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions