Files
LuckyDiamond/luckydiamond/src/assets/js/rest/RestMethods.js
2024-01-28 00:36:07 +01:00

78 lines
1.6 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';
import { DeleteAllCookie } from "@/assets/js/storage/CookieStorage";
export async function Post(url = "", data = {}) {
try {
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
},
body: JSON.stringify(data),
redirect: "follow"
});
if (!response.ok) {
console.log("Fetch error:", response.status);
}
return await response.json();
} catch (error) {
console.log("Fetch error:", error);
}
}
export async function GetCurrentMoney(authToken, searchToken) {
const data = {
AUTHTOKEN: authToken,
SearchToken: searchToken
};
try {
const response = await fetch(`${BackendApiUrl}/Payment/UserMoney`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
redirect: "follow"
});
if (!response.ok) {
DeleteAllCookie()
console.log("Fetch error:", response.status);
}
return await response.json();
} catch (error) {
console.log("Fetch error:", error);
}
}
export async function GetChatHistory() {
try {
const response = await fetch(`${BackendApiUrl}/ChatHistory/GetChatHistory`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: "",
redirect: "follow"
});
if (!response.ok) {
console.log("Fetch error:", response.status);
}
return await response.json();
} catch (error) {
console.log("Fetch error:", error);
}
}