function fetchdata(){

  imgToggle();
  req =  new XMLHttpRequest();
  req.open("GET",'https://contesttrackerapi.herokuapp.com/',true);
  req.send();
  req.onload = function(){
    res = JSON.parse(req.responseText);

    imgToggle();
    putdata(res);

    // cache creation
    now = (new Date()).getTime()/1000;
    localStorage.cache  = req.responseText;
    localStorage.time = now;
        
  };
  req.onerror = function(){
    imgToggle();
    if(localStorage.cache){
      localData = JSON.parse(localStorage.cache);
      putdata(localData);
    }
  };
}
// passes the recieved response to putdata()
passes the recieved response to putdata()
passes the recieved response to putdata ()
function fetchdata(){
  imgToggle();
  req =  new XMLHttpRequest();
  req.open("GET",'https://contesttrackerapi.herokuapp.com/',true);
  req.send();
  req.onload = function(){
    res = JSON.parse(req.responseText);
    imgToggle();
    putdata(res);
    now = (new Date()).getTime()/1000;
    localStorage.cache  = req.responseText;
    localStorage.time = now;
  };
  req.onerror = function(){
    imgToggle();
    if(localStorage.cache){
      localData = JSON.parse(localStorage.cache);
      putdata(localData);
    }
  };
}
function fetchdata ( ) { imgToggle ( ) ; req = new XMLHttpRequest ( ) ; req . open ( "GET" , 'https://contesttrackerapi.herokuapp.com/' , true ) ; req . send ( ) ; req . onload = function ( ) { res = JSON . parse ( req . responseText ) ; imgToggle ( ) ; putdata ( res ) ; now = ( new Date ( ) ) . getTime ( ) / 1000 ; localStorage . cache = req . responseText ; localStorage . time = now ; } ; req . onerror = function ( ) { imgToggle ( ) ; if ( localStorage . cache ) { localData = JSON . parse ( localStorage . cache ) ; putdata ( localData ) ; } } ; }
passes the recieved response to putdata()
passes the recieved response to putdata ()
// cache creation