From 24a743fefab1049429206e52a941215e3283efd3 Mon Sep 17 00:00:00 2001 From: Kostya Date: Sun, 4 Feb 2024 16:15:44 +0300 Subject: [PATCH] added crash-api --- .../src/assets/js/games/crash/CrashAPI.js | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 luckydiamond/src/assets/js/games/crash/CrashAPI.js diff --git a/luckydiamond/src/assets/js/games/crash/CrashAPI.js b/luckydiamond/src/assets/js/games/crash/CrashAPI.js new file mode 100644 index 0000000..a3c306f --- /dev/null +++ b/luckydiamond/src/assets/js/games/crash/CrashAPI.js @@ -0,0 +1,63 @@ +import { BackendApiUrl } from '@/properties/Сonfig.js'; + +export async function JoinCrashGame(userData, amount) { + const data = { + userCredentials: { + searchToken: userData.searchToken, + authtoken: userData.authtoken + }, + bid: amount + } + + try { + const response = await fetch(`${BackendApiUrl}/GameCrash/JoinCrashGame`, { + 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') + } +} + +export async function ExitAndTakeMoneyFromCrashGame(userData) { + const data = { + exitUserCredentials: { + searchToken: userData.searchToken, + authtoken: userData.authtoken + } + } + + try { + const response = await fetch(`${BackendApiUrl}/GameCrash/ExitAndTakeMoneyFromCrash`, { + 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