MCPcopy Create free account
hub / github.com/error311/FileRise / apiPost

Function apiPost

public/js/aiChat.js:49–66  ·  view source on GitHub ↗
(path, payload)

Source from the content-addressed store, hash-verified

47}
48
49async function apiPost(path, payload) {
50 const resp = await fetch(withBase(path), {
51 method: 'POST',
52 credentials: 'include',
53 headers: {
54 'Content-Type': 'application/json',
55 'X-CSRF-Token': csrfToken(),
56 Accept: 'application/json'
57 },
58 body: JSON.stringify(payload || {})
59 });
60
61 const body = await safeJson(resp);
62 if (!resp.ok || !body || body.ok === false) {
63 throw new Error((body && (body.error || body.message || body.assistant)) || `HTTP ${resp.status}`);
64 }
65 return body;
66}
67
68function makeEl(tag, attrs = {}, html = '') {
69 const el = document.createElement(tag);

Callers 4

saveRecipeDraftFunction · 0.70
deleteRecipeFunction · 0.70
toggleRecipePinFunction · 0.70
sendMessageFunction · 0.70

Calls 3

withBaseFunction · 0.85
csrfTokenFunction · 0.70
safeJsonFunction · 0.70

Tested by

no test coverage detected