Jquery - Requests from time to time, error 429

1

I'm doing verification in an interval of time to bring the notifications, the problem throws me the following error:

Error :    429 (Too Many Requests)

Does anyone know how I can prevent this?

  

Current code:

setInterval(function(){
    refresh() 
}, 5000);

function refresh(){
    $.ajax({
        type: 'GET',
        url: 'api/notify',
        success: function(res){
            if(data != res.length){
                // console.log('actualizar!')
                data = res.length
                var obj = JSON.parse(JSON.stringify(res))
                $.each( obj, function( key, value ) {
                    var num = key + 1
                    mensaje += "Mensaje "+ num +": "+ value.mensaje
                });
                $('.messages').text(mensaje)
            }else{
                // console.log('no actualizar!')
            }
        }
    });
}
    
asked by DoubleM 18.12.2018 в 20:07
source

0 answers