MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / post

Function post

packages/react/src/api/shell-host.ts:148–168  ·  view source on GitHub ↗
(path: string, payload: Record<string, unknown>)

Source from the content-addressed store, hash-verified

146 };
147
148 const post = async (path: string, payload: Record<string, unknown>): Promise<unknown> => {
149 const response = await doFetch(`${getExecutorApiBaseUrl()}${path}`, {
150 method: "POST",
151 headers: requestHeaders(),
152 body: JSON.stringify(payload),
153 });
154 if (!response.ok) {
155 const text = await response.text();
156 // An approval that outlived its window is an ordinary outcome, not a
157 // fault: nothing ran, and the fix is to trigger the action again. Say that
158 // instead of surfacing the transport's error body, which reached the user
159 // as a raw `ExecutionNotFoundError` inside a JSON-RPC envelope.
160 if (response.status === APPROVAL_EXPIRED_STATUS) {
161 // oxlint-disable-next-line executor/no-try-catch-or-throw, executor/no-error-constructor -- boundary: the shell's tool proxy is Promise-based and surfaces rejections as component errors
162 throw new Error(APPROVAL_EXPIRED_MESSAGE);
163 }
164 // oxlint-disable-next-line executor/no-try-catch-or-throw, executor/no-error-constructor -- boundary: the shell's tool proxy is Promise-based and surfaces rejections as component errors
165 throw new Error(text || `Executor API request failed with ${response.status}`);
166 }
167 return response.json();
168 };
169
170 return {
171 getHostContext: () => ({ theme: prefersDark() ? "dark" : "light" }),

Callers 1

createHttpShellHostFunction · 0.70

Calls 4

getExecutorApiBaseUrlFunction · 0.90
requestHeadersFunction · 0.85
textMethod · 0.65
jsonMethod · 0.65

Tested by

no test coverage detected