Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
UncaughtType Error when using axios in Vue 3

I am trying to use axios in my Vue3 app to consume APIs. This is the script of my component:

export default {
  name: "Step2",
  data() {
    return {
      loading: true;
    };
  },
  mounted() {
    this.loading = false;
  },
  methods: {
    makeRequest() {
      console.log('Making request...')
      this.axios.get('https://jsonplaceholder.typicode.com/users').then((response) => {
        console.log("test");
      });
    }
  }
};

I imported axios like so:

import axios from 'axios'
import VueAxios from 'vue-axios'
...
const app = createApp(App)
app.use(VueAxios, axios)

When I press the button to make the request, I always get the following error:

Uncaught TypeError: can't convert undefined to object
    mergeConfig axios.js:1308
    request axios.js:1431
    method axios.js:1521
    wrap axios.js:7
    makeRequest Step2.vue:77
    0 Step2.vue:28
    ...

I have tried using different browsers but had no luck. I appreciate every suggestion.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Do you need VueAxios? Basically all you need to do is in your main:

import axios from 'axios'
app.config.globalProperties.axios = axios;

And then it's available on the components globally:

methods: {
makeRequest() {
  console.log('Making request...')
  this.axios.get('https://jsonplaceholder.typicode.com/users')
      .then((response) => {
         console.log("test");
      });

You don't have to add axios globally to your app, you can also add it only to the components that use it:

import axios from 'axios'
export default {
  name: "Step2",
  data() {
    return {
      loading: true;
    };
  },
  mounted() {
    this.loading = false;
  },
  methods: {
    makeRequest() {
      console.log('Making request...')
      axios.get('https://jsonplaceholder.typicode.com/users').then((response) => {
        console.log("test");
      });
    }
  }
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!