src/store/auth.module.js
//to check if user is authenticated
to check if user is authenticated
to check if user is authenticated
async checkAuth(context) {
      if (JwtService.getToken()) {
        try {
          let res = await ApiService.checkAuth(JwtService.getToken());
          context.commit("setUser", res.data);
        } catch (err) {
          context.commit("setError", err.response);
        }
      } else {
        context.commit("logOut");
      }
    }
async checkAuth ( context ) { if ( JwtService . getToken ( ) ) { try { let res = await ApiService . checkAuth ( JwtService . getToken ( ) ) ; context . commit ( "setUser" , res . data ) ; } catch ( err ) { context . commit ( "setError" , err . response ) ; } } else { context . commit ( "logOut" ) ; } }
to check if user is authenticated
to check if user is authenticated