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