MCPcopy
hub / github.com/FujiwaraChoki/MoneyPrinter / apiRequest

Function apiRequest

Frontend/app.js:30–50  ·  view source on GitHub ↗
(path, options = {})

Source from the content-addressed store, hash-verified

28
29// ===== API HELPERS =====
30async function apiRequest(path, options = {}) {
31 const endpoint = path.startsWith("/") ? path : `/${path}`;
32
33 async function request(baseUrl) {
34 const response = await fetch(`${baseUrl}${endpoint}`, options);
35 const data = await response.json();
36 if (!response.ok) {
37 throw new Error(data.message || `Request failed with status ${response.status}`);
38 }
39 return data;
40 }
41
42 try {
43 return await request(API_BASE_URL);
44 } catch (firstError) {
45 if (API_BASE_URL !== API_FALLBACK_URL) {
46 return request(API_FALLBACK_URL);
47 }
48 throw firstError;
49 }
50}
51
52function setModelOptions(models, preferredModel) {
53 aiModel.innerHTML = "";

Callers 5

loadOllamaModelsFunction · 0.85
pollJobFunction · 0.85
cancelGenerationFunction · 0.85
uploadSongsFunction · 0.85
generateVideoFunction · 0.85

Calls 1

requestFunction · 0.85

Tested by

no test coverage detected