diff --git a/luckydiamond/src/assets/js/games/saper/SaperAPI.js b/luckydiamond/src/assets/js/games/saper/SaperAPI.js index ce9a2ee..ac2b395 100644 --- a/luckydiamond/src/assets/js/games/saper/SaperAPI.js +++ b/luckydiamond/src/assets/js/games/saper/SaperAPI.js @@ -25,4 +25,32 @@ export async function GetPercentageSteps(CrystalsCount) { catch (error) { console.log('Fetch Error!') } +} + +export async function GetUserData(SearchToken, AuthToken) { + const data = { + SearchToken: SearchToken, + Authtoken: AuthToken + } + + try { + const response = await fetch(`${BackendApiUrl}/GameMines/GetCurrentData`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(data), + redirect: 'follow' + }) + + if (!response.ok) { + console.log('Fetch error:', response.status) + } + + console.log(response) + return await response.json() + } + catch (error) { + console.log('Fetch error') + } } \ No newline at end of file diff --git a/luckydiamond/src/pages/games-pages/SapergamePage.vue b/luckydiamond/src/pages/games-pages/SapergamePage.vue index 002eb14..fa7d584 100644 --- a/luckydiamond/src/pages/games-pages/SapergamePage.vue +++ b/luckydiamond/src/pages/games-pages/SapergamePage.vue @@ -134,7 +134,8 @@ import ChatComponent from "@/components/ChatComponent.vue"; import AsideBarElement from "@/components/AsidebarComponent.vue"; import HeaderElementPage from "@/components/HeaderComponent.vue"; -import { GetPercentageSteps } from "@/assets/js/games/saper/SaperAPI"; +import { GetPercentageSteps, GetUserData } from "@/assets/js/games/saper/SaperAPI"; +import { GetCookie } from "@/assets/js/storage/CookieStorage"; import { Swiper, SwiperSlide } from 'swiper/vue'; import 'swiper/css'; @@ -185,6 +186,22 @@ export default { } } }, + async created() { + const AUTHTOKEN = GetCookie('AUTHTOKEN') + const SEARCHTOKEN = GetCookie('SearchToken') + + if (AUTHTOKEN !== null && SEARCHTOKEN !== null) { + try { + await GetUserData(AUTHTOKEN, SEARCHTOKEN) + .then(response => { + console.log(response) + }) + } + catch (e) { + console.error('Error in GetData', e) + } + } + }, methods: { flipCard(index) { if (this.flippedCards.includes(index)) {