Use the Fetch API
Edge components require all HTTP requests to use the Fetch API.
There is no support for other HTTP Clients, and all requests must use fetch.
Edge
async function getData(ids, BASE_DOMAIN, BASE_PATH) {
try {
// Use the environment variables to formulate the Matrix URL of the proxy asset
const query = `${BASE_DOMAIN}${BASE_PATH}_api/components/cards/_nocache?ids=${ids}`;
// Set up the fetch
const response = await fetch(query);
const data = await response.json();
// Return the JSON data for our cardsData
return data;
} catch {
// There is no data, or it could not be formatted (not JSON)
console.log('Data could not be found');
return undefined;
}
}