(url, payload = {})
| 3424 | }; |
| 3425 | |
| 3426 | const apiPost = async (url, payload = {}) => { |
| 3427 | const res = await fetch(withBase(url), { |
| 3428 | method: 'POST', |
| 3429 | credentials: 'include', |
| 3430 | headers: { |
| 3431 | 'Content-Type': 'application/json', |
| 3432 | 'X-CSRF-Token': getCsrf(), |
| 3433 | 'Accept': 'application/json', |
| 3434 | }, |
| 3435 | body: JSON.stringify(payload || {}), |
| 3436 | }); |
| 3437 | const data = await safeJson(res); |
| 3438 | if (!res.ok || !data) { |
| 3439 | throw new Error(data?.error || tf('error', 'Error')); |
| 3440 | } |
| 3441 | if (data.ok !== true) { |
| 3442 | throw new Error(data?.error || tf('error', 'Error')); |
| 3443 | } |
| 3444 | return data; |
| 3445 | }; |
| 3446 | |
| 3447 | const setGatewayTab = (tab) => { |
| 3448 | const t = String(tab || 'shares').toLowerCase() === 'mcp' ? 'mcp' : 'shares'; |
no test coverage detected