const axios = require("axios");
const defaultBaseUrl = "https://gateway-staging.ftlapp.io";
module.exports = {
  // 根据已有token存入localStorage获取用户信息，通过回调回传进行后续操作
  async getInfoResource(baseUrl, route, callBack) {
    if (route.query.token) {
      localStorage.setItem("token", route.query.token);
      let res = await axios.post(`${baseUrl ? baseUrl : defaultBaseUrl}/api/auth/loginWithToken`, null, {
        headers: {
          Authorization: route.query.token,
        },
      });
      if (callBack) {
        callBack(res.data);
      }
    }
  },
};
