Files
LuckyDiamond/luckydiamond/src/assets/js/games/crash/CrashAPI.js
2024-04-17 22:12:11 +02:00

63 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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/ExitAndTakeMoneyFromCrashGame`, {
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')
}
}