MCPcopy Create free account
hub / github.com/solidjs/solid-start / fetchServerFunction

Function fetchServerFunction

packages/start/src/fns/client.ts:68–97  ·  view source on GitHub ↗
(
  base: string,
  id: string,
  options: Omit<RequestInit, "body">,
  args: any[],
)

Source from the content-addressed store, hash-verified

66}
67
68async function fetchServerFunction(
69 base: string,
70 id: string,
71 options: Omit<RequestInit, "body">,
72 args: any[],
73) {
74 const instance = `server-fn:${INSTANCE++}`;
75
76 const response = await initializeResponse(base, id, instance, options, args);
77
78 if (
79 response.headers.has("Location") ||
80 response.headers.has("X-Revalidate") ||
81 response.headers.has("X-Single-Flight")
82 ) {
83 if (response.body) {
84 /* @ts-ignore-next-line */
85 response.customBody = async () => {
86 return await extractBody(instance, true, response.clone());
87 };
88 }
89 return response;
90 }
91
92 const result = await extractBody(instance, true, response.clone());
93 if (response.headers.has("X-Error")) {
94 throw result;
95 }
96 return result;
97}
98
99export function cloneServerReference(id: string) {
100 let baseURL = import.meta.env.BASE_URL ?? "/";

Callers 1

fnFunction · 0.85

Calls 2

extractBodyFunction · 0.90
initializeResponseFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…