first of all thanks in advance for the feedback. As I am new to es6 and vuejs I'm starting to have problems using imported Services module throughout the application. The end goal would be to move everything that uses Axios to one BaseService too.
[Vue warn]: Error in mounted hook: "TypeError: __WEBPACK_IMPORTED_MODULE_0__services_AuthService__.a.getCurrentUser is not a function"
AuthService.js
import BaseService from './BaseService'
export default class AuthService {
setCurretUser( user )
{
localStorage.setItem("currentUser", user);
}
getCurrentUser()
{
return localStorage.getItem("currenUser");
}
}
App.vue
import Axios from 'axios'
import Navbar from './partials/Navbar'
import Sidebar from './partials/Sidebar'
import AuthService from '../services/AuthService'
export default {
name: 'app',
components: {
Navbar,
Sidebar
},
mounted() {
console.log('Component mounted.')
},
created() {
Axios.get('api/user')
.then(function (response) {
AuthService.setCurrentUser(response.data);
console.log(response);
})
.catch(function (error) {
console.log(error);
});
}
}