@devicecloud.dev/dcd
Version:
Better cloud maestro testing
36 lines (35 loc) • 1.29 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchCompatibilityData = fetchCompatibilityData;
exports.clearCompatibilityCache = clearCompatibilityCache;
let cachedCompatibilityData = null;
async function fetchCompatibilityData(apiUrl, apiKey) {
if (cachedCompatibilityData) {
return cachedCompatibilityData;
}
try {
const response = await fetch(`${apiUrl}/results/compatibility/data`, {
headers: {
'Content-Type': 'application/json',
'x-app-api-key': apiKey,
},
method: 'GET',
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const result = await response.json();
if (result.statusCode !== 200 || !result.data) {
throw new Error(result.message || 'Failed to fetch compatibility data');
}
cachedCompatibilityData = result.data;
return result.data;
}
catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
throw new Error(`Failed to fetch compatibility data from API: ${errorMessage}`);
}
}
function clearCompatibilityCache() {
cachedCompatibilityData = null;
}
;