From f9c69c6812ba44430637761b89f119f38440590b Mon Sep 17 00:00:00 2001 From: Nulo Date: Thu, 18 Nov 2021 12:08:27 -0300 Subject: [PATCH] demo: no tener resultados dobles --- demo/demo.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/demo/demo.ts b/demo/demo.ts index 4cfc3c3..bbc5cb8 100644 --- a/demo/demo.ts +++ b/demo/demo.ts @@ -54,18 +54,22 @@ function objectToDom(object: any) { } async function showResponse(statusEl: Element | null, promise: Promise) { - if (statusEl) clear(statusEl); try { const response = await promise; if (statusEl) { + clear(statusEl); statusEl.append("¡Funcionó!"); if (response) { statusEl.append(" Respuesta:", objectToDom(response)); } } else alert(`¡Funcionó!${response ? ` Respuesta: ${response}` : ""}`); } catch (error) { - if (statusEl) statusEl.append("Hubo un error :(", objectToDom(error)); - else alert(`Hubo un error: ${error}`); + if (statusEl) { + clear(statusEl); + statusEl.append("Hubo un error :(", objectToDom(error)); + } else { + alert(`Hubo un error: ${error}`); + } } }