Change rest method

This commit is contained in:
Hepatica
2023-12-02 06:30:55 +01:00
parent 98a39ee763
commit c64b41545d

View File

@@ -24,27 +24,48 @@ export async function Post(url = "", data = {}) {
export async function GetCurrentMoney(authToken, searchToken) { export async function GetCurrentMoney(authToken, searchToken) {
const data = {
AUTHTOKEN: authToken,
SearchToken: searchToken
};
try { try {
const response = await fetch(`${BackendApiUrl}/Payment/GetCurrentMoney`, { const response = await fetch(url, {
method: 'GET', method: "GET",
redirect: 'follow',
headers: { headers: {
'AUTHTOKEN': authToken, "Content-Type": "application/json",
'SearchToken': searchToken, },
'Access-Control-Allow-Origin': '*' body: JSON.stringify(data),
} redirect: "follow"
}); });
if (!response.ok) { if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`); console.log("Fetch error:", response.status);
} }
const data = await response.json(); return await response.json();
console.log(data);
return data;
} catch (error) { } catch (error) {
console.error('There was a problem with the fetch operation:', error); console.log("Fetch error:", error);
} }
// try {
// const response = await fetch(`${BackendApiUrl}/Payment/GetCurrentMoney`, {
// method: 'GET',
// redirect: 'follow',
// headers: {
// '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);
// }
} }