jj
    Preparing search index...

    Function fetchHtml

    • Fetches the contents of a HTML file as string.

      Parameters

      • url: string | URL

        The HTML file location.

      Returns Promise<string>

      The file content as a string.

      Useful for loading HTML templates dynamically. You can use import.meta.resolve('./relative-path-to.html') to resolve paths relative to the current module.

      const template = await fetchHtml('./template.html')
      

      If the response is not ok.