Custom api to update the data

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> 

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: Custom code in head and body tags | Webflow University

Using custom code in an embed component on the page: Custom code | Webflow University

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

1 Like