Upload
This commit is contained in:
+6
-1
@@ -1,6 +1,7 @@
|
||||
// src/api.js
|
||||
|
||||
const API_BASE = import.meta.env.VITE_BOX_API_URL || "http://10.10.10.23:8000";
|
||||
const API_TOKEN = import.meta.env.VITE_BOX_API_TOKEN || "";
|
||||
|
||||
export async function getStatus() {
|
||||
const response = await fetch(`${API_BASE}/status`);
|
||||
@@ -12,9 +13,13 @@ export async function getStatus() {
|
||||
|
||||
export async function sendCommand(command, payload = {}) {
|
||||
console.log("GUI -> API", command, payload);
|
||||
const headers = { "Content-Type": "application/json" };
|
||||
if (API_TOKEN) {
|
||||
headers["X-API-Token"] = API_TOKEN;
|
||||
}
|
||||
const response = await fetch(`${API_BASE}/command`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
headers,
|
||||
body: JSON.stringify({ command, payload }),
|
||||
});
|
||||
if (!response.ok) {
|
||||
|
||||
Reference in New Issue
Block a user