export function getJson(url) { return fetch(url, { headers: getAuthHeaders() }).then(function(r) { return r.json(); }); } export function sendJson(url, method, payload) { return fetch(url, { method: method, headers: getAuthHeaders(), body: JSON.stringify(payload || {}) }).then(function(r) { return r.json(); }); } export function sendJsonBlob(url, method, payload) { return fetch(url, { method: method, headers: getAuthHeaders(), body: JSON.stringify(payload || {}) }).then(function(r) { if (!r.ok) return r.json().then(function(e) { throw new Error(e.error || 'Request failed'); }); return r.blob(); }); } export function deleteJson(url) { return fetch(url, { method: 'DELETE', headers: getAuthHeaders() }).then(function(r) { return r.json(); }); }