YouTube

Animations on setTimeout

HTML rendering via JavaScript (a page is loaded without html tags inside document.body)

async _asyncLoad({requestOptions, callback, props}) {
    try{
      const res = await fetch(this._createUrl(props), requestOptions);
      await this._errorHandler(res);
      callback(await res.json());
    } catch(err){ console.error(err); }
  }
  
_fetchLoad({requestOptions, callback, props}) {
    fetch(this._createUrl(props), requestOptions)
      .then(this._errorHandler)
      .then(res => res.json())
      .then(data => callback(data))
      .catch(err => console.error(err));
  }
_xmlHttpLoad({requestOptions, callback, props}){
    let xhr = new XMLHttpRequest();
    xhr.open('GET', this._createUrl(props));

    xhr.onload = () => {
      if (xhr.status === 200) {
        callback(JSON.parse(xhr.response);
      } else {
        console.error(xhr.statusText)
      }
    };

    xhr.onerror = () => reject(xhr.statusText);

    xhr.send();
  }

youtube task

By Victoria Budyonnaya

youtube task

  • 309