4 ms·
Could you be more specific?
by rendall 1y ago
Could you be more specific?
- aanthonymax 1y agoimport hmpl from "hmpl-js"; const templateFn = hmpl.compile( `<div> <button data-action="increment" id="btn">Click!</button> <div>Clicks: {{#request src="/api/clicks" after="click:#btn"}}{{/request}}</div> </div>` ); const controller = new AbortController(); const clicker = templateFn(({ request: { event } }) => ({ body: JSON.stringify({ action: event.target.getAttribute("data-action") }), signal: controller.signal, })).response; document.querySelector("#app").append(clicker);
- aanthonymax 1y agoIn such code, you are free to specify almost all RequestInit supported by fetch.