(url, headers, init = {})
| 52 | }); |
| 53 | |
| 54 | async function cf(url, headers, init = {}) { |
| 55 | const res = await fetch(url, { headers, ...init }); |
| 56 | let json = {}; |
| 57 | try { |
| 58 | json = await res.json(); |
| 59 | } catch { |
| 60 | // Some DELETE responses are empty. |
| 61 | } |
| 62 | return { ok: res.ok && json.success !== false, json }; |
| 63 | } |
| 64 | |
| 65 | const hasCode = (json, ...codes) => |
| 66 | json.errors?.some((error) => codes.includes(error.code)); |
no test coverage detected