(url: RequestInfo, init: RequestInit = defaultRequestInit)
| 183 | }; |
| 184 | |
| 185 | export async function $$fetch(url: RequestInfo, init: RequestInit = defaultRequestInit) { |
| 186 | init.dispatcher = agent; |
| 187 | |
| 188 | try { |
| 189 | const res = await undici.fetch(url, init); |
| 190 | if (res.status >= 400) { |
| 191 | throw new ResponseError(res, url); |
| 192 | } |
| 193 | |
| 194 | if ((res.status < 200 || res.status > 299) && res.status !== 304) { |
| 195 | throw new ResponseError(res, url); |
| 196 | } |
| 197 | |
| 198 | return res; |
| 199 | } catch (err: unknown) { |
| 200 | if (isAbortErrorLike(err)) { |
| 201 | console.log(picocolors.gray('[fetch abort]'), url); |
| 202 | } else { |
| 203 | console.log(picocolors.gray('[fetch fail]'), url, err); |
| 204 | } |
| 205 | |
| 206 | throw err; |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | export { $$fetch as '~fetch' }; |
| 211 |
no outgoing calls
no test coverage detected