JSFiddle - React, Tailwind, and code Playground

by pajakoo

HTML

<iframe id=html src=""></iframe>

JavaScript

function handler() {
  if (this.readyState === this.DONE) {
    if (this.status === 200) {
    console.log(this.response, URL.createObjectURL(this.response))
      // this.response is a Blob, because we set responseType above
      html.src = URL.createObjectURL(this.response);
    } else {
      console.error('XHR failed', this);
    }
  }
}

var html = document.querySelector('#html');
var headers = [
  ['Authorization', 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwic2NvcGUiOiJhZG1pbiIsImlhdCI6MTU3OTg5NDUwN30.sD1hawUBBiO9y_701du-1YKKOgccsKGjF3KPHrq7yWY']
];
var xhr = new XMLHttpRequest();
xhr.open('GET', "https://nd-h5djfbnqq2dfmfsebzewlgp8ho63-3epjlj66na-uc.a.run.app");
xhr.onreadystatechange = handler;
xhr.responseType = 'blob';
xhr.setRequestHeader('Authorization', 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwic2NvcGUiOiJhZG1pbiIsImlhdCI6MTU3OTg5NDUwN30.sD1hawUBBiO9y_701du-1YKKOgccsKGjF3KPHrq7yWY');
/* headers.forEach(function(header) {
  xhr.setRequestHeader(header[0], header[1]);
}); */
xhr.send();