MCPcopy Create free account
hub / github.com/explorerhq/sql-explorer / fetchSchema

Function fetchSchema

explorer/src/js/schemaService.js:3–23  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1const schemaCache = {};
2
3const fetchSchema = async () => {
4
5 const conn = getConnElement().value;
6
7 if (schemaCache[conn]) {
8 return schemaCache[conn];
9 }
10
11 try {
12 const response = await fetch(`${window.baseUrlPath}schema.json/${conn}`);
13 if (!response.ok) {
14 throw new Error(`HTTP error! Status: ${response.status}`);
15 }
16 const schema = await response.json();
17 schemaCache[conn] = schema; // Cache the schema
18 return schema;
19 } catch (error) {
20 console.error('Error fetching table schema:', error);
21 throw error; // Re-throw to handle it in the calling function
22 }
23};
24
25export const SchemaSvc = {
26 get: fetchSchema

Callers

nothing calls this directly

Calls 1

getConnElementFunction · 0.85

Tested by

no test coverage detected