I have a website that uses only HTML and CSS, not frameworks like React, Vue, or Next.js. I’m using an API to get content from Builder.io and display it on my site. Here’s the code I use:
javascript
Copy code
const getPage = async (model, pageURL, containerId, cacheSeconds = 0) => {
const encodedPageURL = encodeURIComponent(pageURL);
const url = ${endpoint}${model}?apiKey=${apiKey}&url=${encodedPageURL}&cacheSeconds=${cacheSeconds}
;
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Failed to fetch content: ${response.statusText}`);
}
const data = await response.json();
const contentDiv = document.getElementById(containerId);
if (!contentDiv) {
throw new Error(`Container element not found: ${containerId}`);
}
contentDiv.innerHTML = data.data.html;
} catch (error) {
console.error('Error fetching content:', error.message);
}
};
However, when I use Builder.io, it tells me that I haven’t integrated Builder into my website, so I have to use the fallback editor. There should be a JavaScript SDK to integrate Builder.io into custom websites, like this:
html
Copy code
<!-- Include Builder.io SDK -->
<script src="https://cdn.builder.io/js/builder.js"></script>
<!-- Initialize Builder.io -->
<script>
builder.init('YOUR_PUBLIC_API_KEY');
</script>
<!-- Add any other head content here (e.g., stylesheets, meta tags) -->
Is Builder.io launching something like this, or is there an SDK I can use? I need to integrate Builder.io into hundreds of sites for our company.
Regards.