MCPcopy Create free account
hub / github.com/QuantiaAI/helm-agents / tryRefresh

Function tryRefresh

apps/web/src/api/client.ts:32–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30let refreshing: Promise<boolean> | null = null;
31
32export function tryRefresh(): Promise<boolean> {
33 if (!refreshing) {
34 refreshing = (async () => {
35 try {
36 const res = await fetch(apiUrl("/auth/refresh"), {
37 method: "POST",
38 credentials: "include",
39 });
40 if (!res.ok) {
41 setAccessToken(null);
42 return false;
43 }
44 const body = (await res.json()) as RefreshResponse;
45 setAccessToken(body.accessToken);
46 return true;
47 } catch {
48 setAccessToken(null);
49 return false;
50 } finally {
51 refreshing = null;
52 }
53 })();
54 }
55 return refreshing;
56}
57
58async function request<T>(path: string, init?: RequestInit): Promise<T> {
59 const send = () =>

Callers 5

AuthProviderFunction · 0.90
requestFunction · 0.85
apiGetTextFunction · 0.85
streamRunFunction · 0.85

Calls 2

apiUrlFunction · 0.85
setAccessTokenFunction · 0.85

Tested by

no test coverage detected