Trying to implement axios in my Vue3 project for fetching APIs. Here is the code snippet from 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 have included axios by importing it as shown below:
import axios from 'axios'
import VueAxios from 'vue-axios'
...
const app = createApp(App)
app.use(VueAxios, axios)
Upon clicking the button to initiate the request, I encounter the following error consistently:
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 switching browsers without success. Any help or suggestions are greatly appreciated.