5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2025-02-17 00:51:49 +00:00

feat: poder cancelar cuando se está haciendo un fetch

si salimos de la página hay que poder cancelar todos los fetchs
pendientes sin producir errores
This commit is contained in:
f 2024-07-10 17:06:29 -03:00
parent 5f53abe78a
commit 255ea763b4
No known key found for this signature in database

View file

@ -103,6 +103,8 @@ export default class extends Controller {
this.currentTarget.innerHTML = "";
this.originalValue = [];
const signal = window.abortController?.signal;
for (const itemTarget of this.itemTargets) {
if (!itemTarget.dataset.value) continue;
if (!this.isChecked(itemTarget)) continue;
@ -114,8 +116,7 @@ export default class extends Controller {
this.currentTarget.appendChild(placeholder);
// TODO: Renderizarlas todas juntas
fetch(this.newArrayValueURL)
fetch(this.newArrayValueURL, { signal })
.then((response) => response.text())
.then((body) => {
const template = document.createElement("template");