Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142239

Best way to recurrently call an external API in JS/Sails.JS?

$
0
0

I'm actually working on an SailsJS app and need to make recurrent call to a Java API (SpringBoot/Hibernate).

Is there any better way to call this API every x seconds (or on API change), than doing an API Call with a setInterval() function ?

function apiCall(){
  $.get( "myApi/request", function( data ) {
    console.log(data);
  });
}
setInterval(apiCall,1000);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

I've heard about socket but it seams difficult to use when the API is external to the Sails App.


Viewing all articles
Browse latest Browse all 142239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>