import fetch from 'node-fetch';
async function fetchData(url, apiKey) {
try {
const response = await fetch(url, {
method: 'GET',
headers: {
'Authorization': `LMC-API-KEY ${apiKey}`, // Add your API key here
'Content-Type': 'application/json', // Optional: specify content type
},
});
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
// Parse the JSON response
const data = await response.json();
console.log('Data received:', data);
} catch (error) {
console.error('Error fetching data:', error);
}
}
const accountId = '8be7cc82...'; // Replace with your account's ID
const endpoint = `https://cloud.lancom.de/cloud-service-devices/accounts/${accountId}/sites`;
const apiKey = 'ey...aNzo'; // Replace with your actual API key
fetchData(endpoint, apiKey);