mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-21 17:09:09 +01:00
Show response headers
This commit is contained in:
9
src-web/lib/minPromiseMillis.ts
Normal file
9
src-web/lib/minPromiseMillis.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { sleep } from './sleep';
|
||||
|
||||
export async function minPromiseMillis<T>(promise: Promise<T>, millis: number) {
|
||||
const start = Date.now();
|
||||
const result = await promise;
|
||||
const delayFor = millis - (Date.now() - start);
|
||||
await sleep(delayFor);
|
||||
return result;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { invoke } from '@tauri-apps/api';
|
||||
import type { HttpRequest, HttpResponse } from './models';
|
||||
|
||||
export function sendEphemeralRequest(request: HttpRequest): Promise<HttpResponse> {
|
||||
// Ensure it's not associated with an ID
|
||||
const newRequest = { ...request, id: '' };
|
||||
// Remove some things that we don't want to associate
|
||||
const newRequest = { ...request, id: '', requestId: '', workspaceId: '' };
|
||||
return invoke('send_ephemeral_request', { request: newRequest });
|
||||
}
|
||||
|
||||
3
src-web/lib/sleep.ts
Normal file
3
src-web/lib/sleep.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export async function sleep(millis: number) {
|
||||
await new Promise((resolve) => setTimeout(resolve, millis));
|
||||
}
|
||||
Reference in New Issue
Block a user