added request-body for play saper

This commit is contained in:
Kostya
2024-01-21 12:15:52 +03:00
parent 9c0f839356
commit 26d4fd8cda
2 changed files with 38 additions and 2 deletions

View File

@@ -53,4 +53,40 @@ export async function GetUserData(AUTHTOKEN, SearchToken) {
catch (error) {
console.log('Fetch error')
}
}
export async function ClickCirclePlay(InfoUser, ClickedCell) {
const data = {
PuttedMoney: InfoUser.PuttedMoney,
MinesCount: InfoUser.MinesCount,
UserCredentials: {
SearchToken: InfoUser.SearchToken,
AUTHTOKEN: InfoUser.AUTHTOKEN
},
ClickedCell: {
X: ClickedCell.X,
y: ClickedCell.Y
}
}
try {
const response = await fetch(`${BackendApiUrl}/GameMines/Play`, {
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.json())
return await response.json()
}
catch (error) {
console.error('Fetch error')
}
}