let timeRemain = 10000;

function getData() {
  var dataUpdate = new XMLHttpRequest();
  dataUpdate.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      var data = JSON.parse(this.responseText);
      timeRemain = Math.random() * 10000; // значение для переменной
      console.log(`Start with interval ${timeRemain}`);
      clearInterval(intervarID)
      intervarID = setInterval(getData, timeRemain)
    }
  };
  dataUpdate.open("GET", "https://jsonplaceholder.typicode.com/posts/1", true);
  dataUpdate.send();
}

document.addEventListener("DOMContentLoaded", function() {
  getData();
});

console.log(`Start with interval ${timeRemain}`);
let intervarID = setInterval(getData, timeRemain)

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.