text: import jwtDecode from "jwt-decode";
  import http from "./httpServices";
  import { apiEndpoint } from "../config.json";
  const apiUrl = apiEndpoint + "/auth";
  const tokenKey = "token";
  
  http.setJwt(getJwt());
  
  async function login(email, password) {
    const { data: jwt } = await http.post(apiUrl, {
      email,
      password
    });
    localStorage.setItem(tokenKey, jwt);
  }
  
  function loginWithJwt(jwt) {
    localStorage.setItem(tokenKey, jwt);
  }
  
  function logout() {
    localStorage.removeItem(tokenKey);
  }
  
  function getCurrentUser() {
    try {
      const jwt = localStorage.getItem(tokenKey);
      return jwtDecode(jwt);
    } catch (err) {
      return null;
    }
  }
  
  function getJwt() {
    return localStorage.getItem("token");
  }
  
  export default {
    login,
    loginWithJwt,
    logout,
    getCurrentUser,
    getJwt
  };
  