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.