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

Function postJson

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

Source from the content-addressed store, hash-verified

68const cookieOf = (identity: Identity): string => identity.headers?.["cookie"] ?? "";
69
70const postJson = (target: TargetShape, path: string, identity: Identity, body: unknown) =>
71 Effect.promise(async () => {
72 const response = await fetch(new URL(path, target.baseUrl), {
73 method: "POST",
74 headers: {
75 "content-type": "application/json",
76 origin: new URL(target.baseUrl).origin,
77 cookie: cookieOf(identity),
78 },
79 body: JSON.stringify(body),
80 });
81 if (!response.ok) {
82 throw new Error(`${path} failed (${response.status}): ${await response.text()}`);
83 }
84 return response;
85 });
86
87/** The identity re-bound to the refreshed session cookie a response set. */
88const withRefreshedSession = (identity: Identity, response: Response): Identity => {

Callers 2

joinOrgFunction · 0.70
createAnotherOrgFunction · 0.70

Calls 3

cookieOfFunction · 0.70
textMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected