Comment by tosh 7 days ago Is there a problem with XMLHTTPRequest?When you say customizable: how? Can you give an example? 4 comments tosh Reply aanthonymax 7 days ago It's old. You can specify AbortController, for example. rendall 6 days ago Could you be more specific? aanthonymax 6 days ago import 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 6 days ago In such code, you are free to specify almost all RequestInit supported by fetch.
aanthonymax 7 days ago It's old. You can specify AbortController, for example. rendall 6 days ago Could you be more specific? aanthonymax 6 days ago import 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 6 days ago In such code, you are free to specify almost all RequestInit supported by fetch.
rendall 6 days ago Could you be more specific? aanthonymax 6 days ago import 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 6 days ago In such code, you are free to specify almost all RequestInit supported by fetch.
aanthonymax 6 days ago import 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 6 days ago In such code, you are free to specify almost all RequestInit supported by fetch.
It's old. You can specify AbortController, for example.
Could you be more specific?
import 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);
In such code, you are free to specify almost all RequestInit supported by fetch.