(input: RequestInfo | URL, init?: RequestInit)
| 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, |
nothing calls this directly
no test coverage detected