(url)
| 3408 | }; |
| 3409 | |
| 3410 | const apiGet = async (url) => { |
| 3411 | const res = await fetch(withBase(url), { |
| 3412 | method: 'GET', |
| 3413 | credentials: 'include', |
| 3414 | headers: { 'Accept': 'application/json' }, |
| 3415 | }); |
| 3416 | const data = await safeJson(res); |
| 3417 | if (!res.ok || !data) { |
| 3418 | throw new Error(data?.error || tf('error', 'Error')); |
| 3419 | } |
| 3420 | if (data.ok !== true) { |
| 3421 | throw new Error(data?.error || tf('error', 'Error')); |
| 3422 | } |
| 3423 | return data; |
| 3424 | }; |
| 3425 | |
| 3426 | const apiPost = async (url, payload = {}) => { |
| 3427 | const res = await fetch(withBase(url), { |
no test coverage detected