Coder Social home page Coder Social logo

Comments (4)

yeloginov avatar yeloginov commented on May 22, 2024 1

Hello!
I have the same issue. Just declaring the axios I receive the error in the console. As well as for @jacquesearle96 axios works further after the error.

My code:

main.js

...
import axios from 'axios';
import App from './components/app.js'

const app = createApp(App)
axios.defaults.baseURL = 'http://localhost:8081'
axios.defaults.responseType = 'json'

app.use(axios)
app.use(router)
app.mount('#root')

store.js

...
import axios from 'axios'

export const useLabelStore = defineStore('label', {
    state: () => {
        return {
            label: [],
        }
    },

    actions: {
      load() {
        axios
            .get('/config/language')
            .then(response => { this.label = response.data })
      },
    },
  })

Using https://unpkg.com/[email protected]/dist/esm/axios.min.js

Thanks!

from axios.

jacquesearle96 avatar jacquesearle96 commented on May 22, 2024

vite: "5.2.10"

from axios.

partg952 avatar partg952 commented on May 22, 2024

can you share the code snippet where you are making the api call?

from axios.

jacquesearle96 avatar jacquesearle96 commented on May 22, 2024

can you share the code snippet where you are making the api call?

Hi @partg952 the error doesn't only show up when I make an API call - it shows as soon as I launch the app (no API calls happen when I view the login screen).

Below is the axios.js file I inject in my store.js files I use to make API calls:
image

Below is my store.js file. import axios from '@axios' injects the above mentioned axios.js file:
image

Above @axios is defined in my vite.config.js file:

'@axios': fileURLToPath(new URL('./src/plugins/axios',
                import.meta.url)),

from axios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.