MCPcopy Index your code
hub / github.com/upstash/jstack / jfetch

Function jfetch

packages/jstack/src/server/client.ts:136–157  ·  view source on GitHub ↗
(input: RequestInfo | URL, init?: RequestInit)

Source from the content-addressed store, hash-verified

134 } = options ?? ({} as ClientConfig)
135
136 const jfetch = async (input: RequestInfo | URL, init?: RequestInit) => {
137 // remove baseUrl from input if already included, for example during SSR
138 const inputPath = input.toString().replace(baseUrl, "")
139 const targetUrl = baseUrl + inputPath
140
141 const res = await fetch(targetUrl, {
142 ...init,
143 credentials,
144 cache: "no-store",
145 })
146
147 if (!res.ok) {
148 const message = await res.text()
149 throw new HTTPException(res.status as ContentfulStatusCode, {
150 message,
151 res,
152 })
153 }
154
155 res.json = () => parseJsonResponse(res)
156 return res
157 }
158
159 const baseClient = hc(baseUrl, {
160 ...opts,

Callers

nothing calls this directly

Calls 1

parseJsonResponseFunction · 0.85

Tested by

no test coverage detected