Im trying to create an api service using this sintax
apiservice.js
import axios from 'axios'
import * as users from '@/plugins/apiservice/modules/users';
const apiservice = axios.create({
baseURL: process.env.VUE_APP_URL,
withCredentials: false,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${localStorage.getItem('sessionToken')}`
},
})
export default {apiservice, users};
users.js
import apiservice from "@/plugins/apiservice";
const login = async (params) => {
try {
const result = await apiservice.post('/login', params);
return result.data;
} catch (error) {
return error;
}
}
export {login};
Component.vue
import apiservice from '@/plugins/apiservice';
const response = await apiservice.users.login(this.loginData);
I got this error when i enter data TypeError: plugins_apiservice__WEBPACK_IMPORTED_MODULE_2_.default.post is not a function
NOTE 1: I tried a GET request to test the connection and i got 200 response
NOTE 2: If a use the exact login function inside apiservice, it works perfectly