worker-tools/html

Integrate with existing worker code?

ZebraFlesh opened this issue · 2 comments

How can I integrate this to an existing worker? That is, I'm already able to fetch and return a complete HTML document. But I'd like to use HTMLRewriter to append some HTML to the document. I can't quite figure it out from the getclaps example -- everything seems to be based around using the HTMLResponse function.

qwtel commented

everything seems to be based around using the HTMLResponse function.

Yes that is correct. This library isn't really intended to work with HTMLRewriter. As a workaround you could use something like

await new HTMLResponse(html`...`).text()

Thanks, that works!