Sha256: ee1befa3b3ef9a886e5c6751be85103c2066f4a48c412f83448ef0f5aa89eae5

Contents?: true

Size: 460 Bytes

Versions: 46

Compression:

Stored size: 460 Bytes

Contents

async function fetchHTML(url, selector) {
  const response = await fetch(url || window.document.location);
  if (response.ok) {
    const html = await response.text();
    const doc = new DOMParser().parseFromString(html, "text/html");
    return {
      fragment: selector ? doc.querySelector(selector).outerHTML : null,
      title: doc.title,
      doc,
    };
  } else {
    throw new Error(`Error fetching HTML from ${url}`);
  }
}

export { fetchHTML };

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
lookbook-1.3.0 app/assets/lookbook/js/helpers/request.js
lookbook-1.2.1 app/assets/lookbook/js/helpers/request.js
lookbook-1.2.0 app/assets/lookbook/js/helpers/request.js
lookbook-1.1.1 app/assets/lookbook/js/helpers/request.js
lookbook-1.1.0 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.8 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.7 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.6 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.5 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.4 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.3 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.2 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.1 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.0 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.0.rc.3 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.0.rc.2 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.0.rc.1 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.0.beta.8 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.0.beta.7 app/assets/lookbook/js/helpers/request.js
lookbook-1.0.0.beta.6 app/assets/lookbook/js/helpers/request.js