MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / get

Function get

_datafiles/html/admin/static/js/api.js:177–192  ·  view source on GitHub ↗

* GET request. * @param {string} path * @param {boolean} [bypassCache=false] - when true, skips the cache read and * writes the fresh result back into it. * @returns {Promise }

(path, bypassCache = false)

Source from the content-addressed store, hash-verified

175 * @returns {Promise<APIResult>}
176 */
177 async function get(path, bypassCache = false) {
178 if (!bypassCache) {
179 const cached = _cacheGet(path);
180 if (cached && Date.now() < cached.expires) {
181 console.log('Loaded from cache:', path);
182 return cached.result;
183 }
184 }
185
186 const result = await request('GET', path);
187 if (result.ok) {
188 console.log('Loaded new:', path);
189 _cacheSet(path, { result, expires: Date.now() + CACHE_TTL_MS });
190 }
191 return result;
192 }
193
194 /**
195 * POST request.

Callers

nothing calls this directly

Calls 4

_cacheGetFunction · 0.85
requestFunction · 0.85
_cacheSetFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected