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

Function postJson

e2e/cloud/connection-owner-isolation.test.ts:68–86  ·  view source on GitHub ↗
(target: TargetShape, path: string, identity: Identity, body: unknown)

Source from the content-addressed store, hash-verified

66// responses re-seal the session when the active org changes.
67
68const postJson = (target: TargetShape, path: string, identity: Identity, body: unknown) =>
69 Effect.promise(async () => {
70 const response = await fetch(new URL(path, target.baseUrl), {
71 method: "POST",
72 headers: {
73 // The identity's own headers (session cookie + org selector) exactly
74 // as its API client would send them — org-scoped endpoints fail
75 // closed without the selector.
76 ...(identity.headers ?? {}),
77 "content-type": "application/json",
78 origin: new URL(target.baseUrl).origin,
79 },
80 body: JSON.stringify(body),
81 });
82 if (!response.ok) {
83 throw new Error(`${path} failed (${response.status}): ${await response.text()}`);
84 }
85 return response;
86 });
87
88/** The identity re-bound to the refreshed session cookie a response set,
89 * scoped to `orgSelector` via the selector header (see switchOrg). */

Callers 2

joinOrgFunction · 0.70
createAnotherOrgFunction · 0.70

Calls 2

textMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected