adding missed commit for integrating requests

This commit is contained in:
xyroscar
2025-12-31 18:37:17 -08:00
parent 031f0514d6
commit 75210ec73a

View File

@@ -26,6 +26,7 @@
delete_request, delete_request,
} from "$lib/services/collections"; } from "$lib/services/collections";
import { get_resolved_variables } from "$lib/services/variables"; import { get_resolved_variables } from "$lib/services/variables";
import { send_request } from "$lib/services/http";
import type { Workspace } from "$lib/types/workspace"; import type { Workspace } from "$lib/types/workspace";
import type { Collection } from "$lib/types/collection"; import type { Collection } from "$lib/types/collection";
import type { Request, HttpMethod } from "$lib/types/request"; import type { Request, HttpMethod } from "$lib/types/request";
@@ -191,50 +192,30 @@
loading = true; loading = true;
response = null; response = null;
// Simulate API request (will be replaced with actual Tauri call later)
const startTime = Date.now();
try { try {
// Mock response for now const httpResponse = await send_request(request, resolvedVariables);
await new Promise((resolve) =>
setTimeout(resolve, 500 + Math.random() * 1000)
);
const mockBody = JSON.stringify( const contentType =
{ httpResponse.headers.find((h) => h.key.toLowerCase() === "content-type")
success: true, ?.value ?? "text/plain";
message: "This is a mock response",
data: {
id: 1,
name: "Example",
timestamp: new Date().toISOString(),
},
},
null,
2
);
response = { response = {
status: 200, status: httpResponse.status,
statusText: "OK", statusText: httpResponse.statusText,
headers: [ headers: httpResponse.headers,
{ key: "Content-Type", value: "application/json" }, body: httpResponse.body,
{ key: "X-Request-Id", value: crypto.randomUUID() }, contentType,
{ key: "Cache-Control", value: "no-cache" }, duration: httpResponse.timeMs,
], size: httpResponse.sizeBytes,
body: mockBody,
contentType: "application/json",
duration: Date.now() - startTime,
size: new Blob([mockBody]).size,
}; };
} catch (error) { } catch (error) {
response = { response = {
status: 500, status: 0,
statusText: "Error", statusText: "Error",
headers: [], headers: [],
body: JSON.stringify({ error: "Request failed" }), body: error instanceof Error ? error.message : "Request failed",
contentType: "application/json", contentType: "text/plain",
duration: Date.now() - startTime, duration: 0,
size: 0, size: 0,
}; };
} finally { } finally {