<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Embeding API Element in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Embeding-API-Element/m-p/938818#M38223</link>
    <description>&lt;P&gt;Thank you for the reply, thankfully CORS isn't going to be an issue since it's on a same domain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I digged around with the Fetch method and came up with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;fetch("https://domain.com/embed/benefits")
  .then((response) =&amp;gt; response.json()) // Parse the JSON response
  .then((data) =&amp;gt; {
    const benefits = data.benefits;

    document.getElementById("benefits-section").innerHTML = `
      &amp;lt;h2&amp;gt;Benefits&amp;lt;/h2&amp;gt;
      &amp;lt;ul&amp;gt;
        ${benefits.map((benefit) =&amp;gt; `&amp;lt;li&amp;gt;${benefit}&amp;lt;/li&amp;gt;`).join("")}
      &amp;lt;/ul&amp;gt;
    `;
  })
  .catch((error) =&amp;gt; console.error("Error fetching data:", error));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;So basically, I just use the "benefits-section" ID to render elements?&lt;/P&gt;</description>
    <pubDate>Wed, 06 Mar 2024 15:30:29 GMT</pubDate>
    <dc:creator>jupiter1</dc:creator>
    <dc:date>2024-03-06T15:30:29Z</dc:date>
    <item>
      <title>Embeding API Element</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Embeding-API-Element/m-p/935518#M38175</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;Hope you're well.&lt;BR /&gt;&lt;BR /&gt;Kind of a novice question. I've a API embed with me and I want to add it to a landing page but I'm little consued as to how to actually implement it? Someone said to me just wrap it in an &amp;lt;iframe&amp;gt; and drop it on the page but this obviously kills the performance and it takes a while to load that element.&lt;BR /&gt;&lt;BR /&gt;API looks like this --&amp;gt; domain.com/embed/benefits&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;It's coming from a main website which is not on HubSpot. They prefer adding the API so they don't have to constatnly update the copy on two places.&lt;BR /&gt;&lt;BR /&gt;Can anyone help?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 18:59:31 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Embeding-API-Element/m-p/935518#M38175</guid>
      <dc:creator>jupiter1</dc:creator>
      <dc:date>2024-02-29T18:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Embeding API Element</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Embeding-API-Element/m-p/936275#M38176</link>
      <description>&lt;P&gt;Hi, &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/719640"&gt;@jupiter1&lt;/a&gt;&lt;/SPAN&gt; &lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Welcome to our community. Thanks for your question.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It sounds like you're looking to integrate dynamic content from an external API into a HubSpot landing page. Embedding an API directly into a webpage, as you've described, isn't exactly how APIs are typically used. Instead, APIs are interfaces that allow your website or application to retrieve and display data programmatically from another service.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can't put the API endpoint in an iframe&amp;gt; because it might not work well (APIs don't return HTML by default, but instead JSON data formats), you need to consider other options:&lt;/P&gt;
&lt;UL&gt;
 &lt;LI&gt;&lt;A href="https://developers.hubspot.com/docs/cms/data/serverless-functions" target="_blank"&gt;Serverless functions (HubSpot Enterprise)&lt;/A&gt;&lt;BR /&gt;or&lt;/LI&gt;
 &lt;LI&gt;Making AJAX Call from the Client Side (will require some testing to make sure you don't run into CORS issues)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Please let me know if you have any additional questions. &amp;nbsp;— Jaycee&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 21:01:10 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Embeding-API-Element/m-p/936275#M38176</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2024-03-01T21:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Embeding API Element</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Embeding-API-Element/m-p/937929#M38204</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Certainly! If you want to embed an API on a landing page without affecting performance, using an&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;is a common approach. However, you can enhance the loading speed and performance by incorporating asynchronous loading or lazy loading techniques.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2024 13:59:41 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Embeding-API-Element/m-p/937929#M38204</guid>
      <dc:creator>aircompanion10</dc:creator>
      <dc:date>2024-03-05T13:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: Embeding API Element</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Embeding-API-Element/m-p/938818#M38223</link>
      <description>&lt;P&gt;Thank you for the reply, thankfully CORS isn't going to be an issue since it's on a same domain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I digged around with the Fetch method and came up with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;fetch("https://domain.com/embed/benefits")
  .then((response) =&amp;gt; response.json()) // Parse the JSON response
  .then((data) =&amp;gt; {
    const benefits = data.benefits;

    document.getElementById("benefits-section").innerHTML = `
      &amp;lt;h2&amp;gt;Benefits&amp;lt;/h2&amp;gt;
      &amp;lt;ul&amp;gt;
        ${benefits.map((benefit) =&amp;gt; `&amp;lt;li&amp;gt;${benefit}&amp;lt;/li&amp;gt;`).join("")}
      &amp;lt;/ul&amp;gt;
    `;
  })
  .catch((error) =&amp;gt; console.error("Error fetching data:", error));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;So basically, I just use the "benefits-section" ID to render elements?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 15:30:29 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Embeding-API-Element/m-p/938818#M38223</guid>
      <dc:creator>jupiter1</dc:creator>
      <dc:date>2024-03-06T15:30:29Z</dc:date>
    </item>
  </channel>
</rss>

