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) {
const data = {
AUTHTOKEN: authToken,
SearchToken: searchToken
};
try {
const response = await fetch(`${BackendApiUrl}/Payment/GetCurrentMoney`, {
method: 'GET',
redirect: 'follow',
const response = await fetch(url, {
method: "GET",
headers: {
'AUTHTOKEN': authToken,
'SearchToken': searchToken,
'Access-Control-Allow-Origin': '*'
}
"Content-Type": "application/json",
},
body: JSON.stringify(data),
redirect: "follow"
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
console.log("Fetch error:", response.status);
}
const data = await response.json();
console.log(data);
return data;
return await response.json();
} 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);
// }
}