Streaming live at 10am (PST)

Custom api to update the data


#1

I want to update this number through client’s api : http://data.memopresso.com/api/data/count
00

where should I put the script code?

 <script>
      getPrintCount();

      function getPrintCount(){
          $.ajax({
              url: 'http://data.memopresso.com/api/data/count',
              dataType: 'json',
              type: 'get',
              cache: false,
              success: function(data){
                  document.getElementById("printCount").innerHTML = data.count;
              },
              error: function(data){
                  document.getElementById("printCount").innerHTML = '0';
              }
          });
      }
  </script> 

#2

Hi @yuenletsgo, I woud put that in the Before Body section of custom code in project settings or in page settings. Here are some good resources:

Using custom code in the head and body: https://university.webflow.com/article/how-to-add-custom-head-and-body-code-to-a-webflow-site

Using custom code in an embed component on the page: https://university.webflow.com/article/embed

That code appears to be targeting an element having an ID of “printCount” so make sure there is an element on your page having that matching ID.

I hope this helps