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

Function postJson

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

Source from the content-addressed store, hash-verified

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