mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-08-01 16:02:18 +00:00
Added node info and status qortal requests
This commit is contained in:
committed by
Nicola Benaglia
parent
45b32befb4
commit
2a64a73f0b
@@ -2883,6 +2883,68 @@ export const getDaySummary = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getNodeInfo = async () => {
|
||||
const url = `/admin/info`; // Simplified endpoint URL
|
||||
|
||||
try {
|
||||
const endpoint = await createEndpoint(url); // Assuming createEndpoint is available for constructing the full URL
|
||||
const response = await fetch(endpoint, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Accept: "*/*",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error("Failed to retrieve node info");
|
||||
|
||||
let res;
|
||||
try {
|
||||
res = await response.clone().json();
|
||||
} catch (e) {
|
||||
res = await response.text();
|
||||
}
|
||||
|
||||
if (res?.error && res?.message) {
|
||||
throw new Error(res.message);
|
||||
}
|
||||
|
||||
return res; // Return the full response
|
||||
} catch (error) {
|
||||
throw new Error(error?.message || "Error in retrieving node info");
|
||||
}
|
||||
};
|
||||
|
||||
export const getNodeStatus = async () => {
|
||||
const url = `/admin/status`; // Simplified endpoint URL
|
||||
|
||||
try {
|
||||
const endpoint = await createEndpoint(url); // Assuming createEndpoint is available for constructing the full URL
|
||||
const response = await fetch(endpoint, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Accept: "*/*",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error("Failed to retrieve node status");
|
||||
|
||||
let res;
|
||||
try {
|
||||
res = await response.clone().json();
|
||||
} catch (e) {
|
||||
res = await response.text();
|
||||
}
|
||||
|
||||
if (res?.error && res?.message) {
|
||||
throw new Error(res.message);
|
||||
}
|
||||
|
||||
return res; // Return the full response
|
||||
} catch (error) {
|
||||
throw new Error(error?.message || "Error in retrieving node status");
|
||||
}
|
||||
};
|
||||
|
||||
export const sendCoin = async (data, isFromExtension) => {
|
||||
const requiredFields = ["coin", "amount"];
|
||||
const missingFields: string[] = [];
|
||||
|
Reference in New Issue
Block a user