()
| 1 | const schemaCache = {}; |
| 2 | |
| 3 | const 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 | |
| 25 | export const SchemaSvc = { |
| 26 | get: fetchSchema |
nothing calls this directly
no test coverage detected