pediatric-ai-scribe-v3/public/js/learningHub/api.js
2026-05-08 16:04:21 +02:00

26 lines
800 B
JavaScript

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(); });
}