Files
LuckyDiamond/luckydiamond/src/assets/js/rest/RestMethods.js
Hepatica 59c0457f91 fix bugs
2023-12-02 05:29:29 +01:00

53 lines
1.1 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 Post(url = "", data = {}) {
try {
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
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) {
try {
const response = await fetch(`${BackendApiUrl}/Payment/GetCurrentMoney`, {
method: 'GET',
mode: 'no-cors',
headers: {
"Content-Type": "application/json",
'AUTHTOKEN': authToken,
'SearchToken': searchToken
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log(data);
return data;
} catch (error) {
console.error('There was a problem with the fetch operation:', error);
}
}