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

Function postJson

e2e/cloud/support/session.ts:67–87  ·  view source on GitHub ↗
(
  target: TargetShape,
  path: string,
  identity: Identity,
  body: unknown,
)

Source from the content-addressed store, hash-verified

65 * `AccountNoOrganization` when the org selector header is absent, because the
66 * session's own org is only a default and is never fallen back to. */
67export const postJson = (
68 target: TargetShape,
69 path: string,
70 identity: Identity,
71 body: unknown,
72): Effect.Effect<Response> =>
73 Effect.promise(async () => {
74 const response = await fetch(new URL(path, target.baseUrl), {
75 method: "POST",
76 headers: {
77 ...(identity.headers ?? {}),
78 "content-type": "application/json",
79 origin: new URL(target.baseUrl).origin,
80 },
81 body: JSON.stringify(body),
82 });
83 if (!response.ok) {
84 throw new Error(`${path} failed (${response.status}): ${await response.text()}`);
85 }
86 return response;
87 });
88
89/** The identity re-bound to the refreshed session cookie a response set, and
90 * scoped to `orgSelector` — carrying the cookie alone would leave every

Callers 2

joinOrgFunction · 0.70
createOrgFunction · 0.70

Calls 2

textMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected